home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / jpl_c.zip / USEGUIDE.SI < prev    next >
Text File  |  1988-08-06  |  171KB  |  4,138 lines

  1. .cw10
  2. .po17
  3. .pn 1
  4. .PN 1
  5. .FO                                1-#
  6.                     1. I N T R O D U C T I O N 
  7.  
  8. The   purpose  of  this  manual  is  to  describe  the  use   and 
  9. installation of the Portable C Subroutine Library.   This library 
  10. is  a collection of modules written in the C language  (Reference 
  11. [2]),  that  is  capable  of  equivalent  operation  in  multiple 
  12. environments.   The  library  is  available in  source  form  for 
  13. compilation  and integration into a system library to replace the 
  14. host  vendor C library.   Listings of the portable C library  are 
  15. contained in a separate document (Reference [15]).
  16.  
  17. The  content of the library consists of functions which  minimize 
  18. the visibility of system-specific I/O formats,  the use of system 
  19. commands,  and the reliance on specific system  resources.   Some 
  20. customization   is  necessary,   however,   to  accommodate   the 
  21. ideosyncracies of each new host. Some of these ideosyncracies can 
  22. be  removed  by proper definition of parameters in  header  files 
  23. included  when  the portable library is recompiled.   Others  may 
  24. require  a small amount of code alteration.   A later section  of 
  25. this  document contains information and procedures  for  adapting 
  26. the portable C library in such cases.
  27.  
  28. The  system  I/O interface is restricted to the  functions  sbrk, 
  29. close,  creat,  exit,  lseek,  open,  read,  unlink,  and  write, 
  30. supplied by the host C language vendor.   These are assumed to be 
  31. compatible with UNIXtm conventions.   Another function ,  rename, 
  32. is  assumed,  either  added  by the C language vendor or  by  the 
  33. installer of this library.  The floating point arithmetic  system 
  34. interface consists of only a few functions, such as chrstc, fint, 
  35. ldexp,  astof,  and  ftoa,  that  require some alteration of  the 
  36. source code.   The remainder of the library utilizes the standard 
  37. Kernighan and Ritchie (Reference [2]) C language features.
  38.  
  39. As  many  of the UNIX library functions as were  deemed  portable 
  40. were  included in the portable C library.   These bear  the  same 
  41. names  here  as they do in the parent library.   Other  functions 
  42. have been added for greater utility.
  43.  
  44. Descriptions  in this manual follow the UNIX Programmer's  Manual 
  45. format;  in fact,  the descriptions of the common functions  were 
  46. adapted from the parent manual.  The text is collected into a set 
  47. of subsections, which appear when applicable:
  48.  
  49.      The  heading of each entry gives a very short description of 
  50.      the purpose of the functions in that entry.
  51.  
  52.      The  name subsection lists the exact names of the header  or 
  53.      subroutines covered under the entry.
  54.  
  55.  
  56.  
  57.  
  58.  
  59. *UNIX is a Trademark of Bell Laboratories.
  60.  
  61.      The  synopsis  summarizes  the use  of  the  function  being 
  62.      described,  including required include statements,  formats, 
  63.      and passed parameters.  A few conventions are used:
  64.  
  65.           Boldface words are considered literals,  and are  typed 
  66.           just as they appear.
  67.  
  68.           Square  brackets  [ ] around an argument indicate  that 
  69.           the argument is optional.  When an argument is given as 
  70.           'name', it always refers to a file name.
  71.  
  72.           Ellipses  '...'  are  used to show  that  the  previous 
  73.           argument-prototype may be repeated.
  74.  
  75.           A final convention is used by the commands  themselves.  
  76.           An  argument  beginning with a minus sign '-' is  often 
  77.           taken  to mean some sort of option-specifying  argument 
  78.           even  if  it appears in a position where  a  file  name 
  79.           could  appear.   Therefore,  it is unwise to have files 
  80.           whose names begin  with '-'.
  81.  
  82.      The  description subsection discusses in detail the  subject 
  83.      at hand.
  84.  
  85.      A see also subsection gives pointers to related information.
  86.  
  87.      A   diagnostics   subsection   discusses   the    diagnostic 
  88.      indications  which  may  be produced.   Messages  which  are 
  89.      intended to be self-explanatory are not listed.
  90.  
  91.      The   bugs   subsection  gives  known  bugs  and   sometimes 
  92.      deficiencies.    Occasionally  the  suggested  fix  is  also 
  93.      described.
  94. .pa o
  95. .PN 1
  96. .FO                                2-#
  97.                    2. H E A D E R   L I B R A R Y 
  98.  
  99.  
  100. This  chapter  describes  each of the portable  library  standard 
  101. header files,  which contain definitions of constants and  macros 
  102. to   be  used  when  compiling  user  programs,   and  also  when 
  103. recompiling the portable library itself.   In addition,  global.h 
  104. and stdio.h define global data structures;  global.h is  required 
  105. for  each main segment,  and stdio.h is required for all programs 
  106. which use buffered i/o.
  107.  
  108. Generally,  all macros and constants defined in header files  are 
  109. captalized,  so  that the user may know that they are such.   The 
  110. exceptions  are  the global variables  errno  and  progname,  and 
  111. definitions of stdin, stdout, stderr, tiny, and utiny.
  112.  
  113. Generally,   all   system-dependent  constants  or  switches  are 
  114. contained  in these header files.   Thus customization for a  new 
  115. system   primarily  involves  changing  only  the  header   files 
  116. (stdio.h, mathcons.h).  However some subroutines may also require 
  117. modification.    See   the   customization  notes   for   further 
  118. information concerning this subject.
  119.  
  120. The portable library standard header files are:
  121.  
  122. .uj0
  123.      ctype.h        standard character-type macros
  124.  
  125.      defs.h         standard definitions and selectors file
  126.  
  127.      errno.h        standard error number definition file
  128.  
  129.      global.h       standard global variable header file
  130.  
  131.      mathcons.h     constant file for math functions
  132.  
  133.      mathtyp.h      header file to declare math functions
  134.  
  135.      scrnio.h       terminal display data file
  136.  
  137.      stdio.h        standard buffered i/o definition package
  138.  
  139.      stdtyp.h       standard defined-types file
  140. .uj1
  141. .pa
  142. .hectype.h                                                   ctype.h
  143.  
  144.                  Standard Character-Type Macros
  145.  
  146. NAME
  147.      ctype.h 
  148.  
  149. SYNOPSIS
  150.      #include <ctype.h>
  151.  
  152.      BOOL ISALPHA(c)
  153.      int c;
  154.      . . .
  155.  
  156. DESCRIPTION
  157.      These  macros  classify ASCII-coded integer values by  table 
  158.      lookup.   Each  is a predicate returning nonzero  for  TRUE, 
  159.      zero  for FALSE.   ISASCII is defined on all integer values; 
  160.      the  rest are defined only where ISASCII is TRUE and on  the 
  161.      single  non-ASCII value EOF (see stdio.h).   The  conditions 
  162.      for TRUE are:
  163.  
  164. .uj0
  165.      ISALNUM(c)      c is an alphanumeric character.
  166.  
  167.      ISALPHA(c)      c is a letter.
  168.  
  169.      ISASCII(c)      c is an ASCII character, code less than 0x80.
  170.  
  171.      ISCNTRL(c)      c is a delete character (0x7f)  or  ordinary 
  172.                        control character (less than 0x20).
  173.  
  174.      ISDIGIT(c)      c is a digit.
  175.  
  176.      ISLOWER(c)      c is a lower case letter.
  177.  
  178.      ISOCTAL(c)      c is an octal character.
  179.  
  180.      ISPRINT(c)      c is  a  printing    character,   code   0x20              
  181.                        (space) through 0x7e (tilde).
  182.  
  183.      ISPUNCT(c)      c is a punctuation character (neither control 
  184.                        nor alphanumeric).
  185.  
  186.      ISSPACE(c)      c is a space,  tab, carriage return, newline, 
  187.                        or formfeed.
  188.  
  189.      ISUPPER(c)      c is an upper case letter.
  190. .uj1
  191.  
  192.      The following use the ISUPPER and ISLOWER macros, and return 
  193.      a character:
  194.  
  195. .uj0
  196.      TOLOWER(c)      returns the lower case of c,  or c if it  is 
  197.                      lower case.
  198.  
  199.      TOUPPER(c)      returns upper case of c.
  200. .uj1
  201.  
  202. SEE ALSO
  203.      corresponding list of functions.
  204.  
  205. BUGS
  206.      Because  these are implemented as macros,  side effects  may 
  207.      not  be  handled  correctly;  e.g.   ISALPHA(*s++)  may  not 
  208.      produce the intended result.  Use the function form of these 
  209.      macros in such cases.
  210. .pa
  211. .hedefs.h                                                     defs.h
  212.  
  213.              Standard Definitions and Selectors File
  214.  
  215. NAME
  216.      defs.h 
  217.  
  218. SYNOPSIS
  219.      #include <defs.h>
  220.  
  221.      MAX(a, b)
  222.      ...
  223.  
  224. DESCRIPTION
  225.      The following operators are defined in defs.h:
  226.  
  227. .uj0
  228.      AND            replacement  for  '&&',   the  logical  'and'                               
  229.                     operator.
  230.  
  231.      FOREVER        same as 'for (;;)',  causes an infinite loop.  
  232.  
  233.      IS             replaces   '==',   the  logical   equivalence                    
  234.                     operator.
  235.  
  236.      ISNT           acts as the  non-equivalence operator,  '!='.  
  237.  
  238.      NOT            substitute  for  '!',  the  logical  negation                
  239.                     operator.
  240.  
  241.      OR             replaces  '||',   the  logical   inclusive-or                
  242.                     operator.
  243.  
  244.  
  245.      The standard constants defined in defs.h are the following:
  246.  
  247.      EOF            (-1)
  248.  
  249.      FAIL           1
  250.  
  251.      FALSE          0
  252.  
  253.      NO             0
  254.  
  255.      NULL           0
  256.  
  257.      SUCCESS        0
  258.  
  259.      TRUE           1
  260.  
  261.      YES            1
  262.  
  263.  
  264.      Also in defs.h are several macros:
  265.  
  266.      ABS(x)         returns the absolute value of x.
  267.  
  268.      GZ(x)          returns x if x is greater than zero.  If not,      
  269.                     it returns zero.
  270.  
  271.      LURSHIFT(n, b) returns the value of long n after an unsigned 
  272.                     right shift of b bits.
  273.  
  274.      MAX(x, y)      returns the larger of x and y.
  275.  
  276.      MIN(x, y)      returns the lesser of x and y.
  277.  
  278.      SGN(x)         returns +1 if x is positive,  -1 if negative, 
  279.                     or 0 if 0.
  280.  
  281.      URSHIFT(n, b)  returns  the value of int n  bits  after  an                  
  282.                     unsigned right shift of b bits.
  283.  
  284.    
  285.      Examples:
  286.  
  287.            if (statement1 AND statement2) ...
  288.            x = GZ(x);
  289.            FOREVER ...
  290.            if (op1 IS op2) ...
  291.            if (op1 ISNT op2) ...
  292.            while (NOT x) ...
  293.            while (statement1 OR statement2) ...
  294.            large = MAX(x, y);
  295. .uj1
  296.  
  297. SEE ALSO
  298.      list of corresponding functions.
  299.  
  300. BUGS
  301.      Because ABS,  GZ,  MAX,  MIN, SGN are implemented as macros, 
  302.      side  effects  may not be handled  properly.   For  example, 
  303.      ABS(i++) may be incorrect.   Use the function forms of these 
  304.      macros in such cases.
  305. .pa
  306. .heerrno.h                                                   errno.h
  307.  
  308.               Standard Error Number Definition File
  309.  
  310. NAME
  311.      errno.h 
  312.  
  313. SYNOPSIS
  314.      #include <errno.h>
  315.  
  316. DESCRIPTION
  317.      errno.h  defines error number values.  The only two used  in 
  318.      the portable math library are:
  319.  
  320. .uj0
  321.      ERANGE    computed math value is out of computable range.
  322.      EDOM      function argument is not in defined domain.
  323. .uj1
  324.  
  325.      Other  values of errno may be returned by system  calls  and 
  326.      buffered i/o functions. Typical errno values returned by the 
  327.      system calls used by the portable library are:
  328. .uj0
  329.  
  330.      ENOENT    file does not exist
  331.      E2BIG     argument list too long
  332.      EBADF     bad file descriptor          
  333.      ENOMEM    not enough memory for requested operation         
  334.      EEXIST    file already exists on create request
  335.      EINVAL    invalid argument
  336.      ENFILE    exceeded maximum number of disk files
  337.      EMFILE    exceeded maximum number of file descriptors
  338.      ENOTTY    not a terminal or device to which calls apply
  339.      EACCES    invalid access request
  340.      EIO       i/o error during read or write
  341.      ENXIO     no such device or address
  342.      EPERM     modification forbidden except to owner, superuser
  343.      EFAULT    bad address
  344.      EXDEV     cross-device link attempted
  345.      ENODEV    no such device
  346.      EFBIG     file too large
  347.      ENOSPC    no space left on device
  348.      EROFS     read-only file system
  349.      EMLINK    too many links to a file
  350. .uj1
  351.  
  352. SEE ALSO
  353.      global.h
  354. .pa
  355. .heglobal.h                                                 global.h
  356.  
  357.               Standard Global Variable Header File
  358.  
  359. NAME
  360.      global.h 
  361.  
  362. SYNOPSIS
  363.      #include <global.h>
  364.  
  365.      main(argc, argv)
  366.      STRING *argv;
  367.  
  368. DESCRIPTION
  369.      This  header  declares a global variable errno and a  global 
  370.      variable  string  progname to be used in  those  cases  when 
  371.      argv[0]  does not contain the program name.   The programmer 
  372.      may   use   this   variable   to   record   the   name,   as 
  373.      
  374.           strcpy(progname, "<program name>");  
  375.      
  376.      If arg[0] does contain the name of the invoked program, then 
  377.      the same effect is obtained via 
  378.  
  379.           strcpy(progname, argv[0]);
  380.  
  381.      This  file also contains outrow[] and outcol[] which contain 
  382.      the row and column values of all output channels, indexed by 
  383.      unit  number.    For  buffered  i/o,   these  are  given  by 
  384.      fp->_unit;  for unbuffered i/o, the unit numbers are STDOUT, 
  385.      STDERR, and file descriptors returned by open.
  386. .pa
  387. .hemathcons.h                                             mathcons.h
  388.  
  389.                 Constant File for Math Functions
  390.  
  391. NAME
  392.      mathcons.h 
  393.  
  394. SYNOPSIS
  395.      #include <mathcons.h>
  396.  
  397. DESCRIPTION
  398.      This  header  file  contains  the values  of  the  following 
  399.      machine-dependent constants:
  400.  
  401. .uj0
  402.            BIG10X            10^(2^(BIG10X-1)) < INFINITY
  403.            BIGX             16 * log2(INFINITY) - 1    
  404.            DPRECISION         (int) PRECISION        
  405.            INFINITY         machine infinity, 2(MAXEXP-1) 
  406.            INFINLEG         INFINITY / sqrt(2)        
  407.            LEAST         least double representable    
  408.            LOGINFINITY         largest log argument        
  409.            LOGLEAST         smallest log argument    
  410.            MAXEXP         largest characteristic    
  411.            MAXEXPG         MAXEXP - 3 guard bits    
  412.            MINEXP         smallest characteristic    
  413.            MINEXPG         MINEXP + 3 guard bits    
  414.            PRECISION         -log10 of WASHOUT        
  415.            RTHLFINF         sqrt(INFINITY / 2)        
  416.            SMALLX           16 * log2(LEAST) + 1        
  417.            SYMLEAST         symmetric least (has inverse)
  418.            TANHXBIG         (sig. bits + 2) * ln(2) / 2    
  419.            WASHOUT         1.0 + (x < WASHOUT) = 1.0    
  420. .uj1
  421.  
  422.      mathcons.h  also contains the following  machine-independent 
  423.      constants:
  424.  
  425. .uj0
  426.            CBRTFOUR         cube root of 4    
  427.            CBRTTWO         cube root of 2    
  428.            FADEOUT           Taylor series fadeout term
  429.            FOURTHLOG2         log(2)/4        
  430.            HALFLOG2e         log2(e)/2        
  431.            INVPI         1 / pi        
  432.            LOG2             log of 2 base e    
  433.            LOG2e         log of e base 2    
  434.            LOGe1         log of 10 base e    
  435.            LOG10e         log of e base 10    
  436.            LOG10two         log of 2 base 10    
  437.            MAXANGLE         int(pi * 225)    
  438.            PI             pi            
  439.            PIover2         pi / 2        
  440.            PIover3         pi / 3        
  441.            PIover4         pi / 4        
  442.            PIover6         pi / 6        
  443.            ROOTHALF         square root of 1/2    
  444.            ROOTTWO          square root of 2    
  445.            SQRT3         sqrt(3)        
  446.            SQRT3m1              sqrt(3) - 1        
  447.            TWOLOG2e         2 * log2(e)        
  448.            TWOmSQRT3         2 - sqrt(3)        
  449.            TWOoverPI         2 / pi        
  450. .uj1
  451. .pa
  452. .hemathtyp.h                                               mathtyp.h
  453.  
  454.               Header File to Declare Math Functions
  455.  
  456. NAME
  457.      mathtyp.h 
  458.  
  459. SYNOPSIS
  460.      #include <mathtyp.h>
  461.  
  462. DESCRIPTION
  463.      This  contains  type declarations which define the types  of 
  464.      all  double  math functions in  this  library.   Using  this 
  465.      header  deletes the necessity to declare each math  function 
  466.      separately in user programs.  Included are:
  467.  
  468.           acos      cotan     fmin      modf      sgn
  469.           asin      erf       frexp     ntail     simpson
  470.           atan      erfc      hypot     nprob     sin
  471.           atan2     exp       inverf    pow       sinh
  472.           atof      fabs      inverfc   randexp   sqrt
  473.           cbrt      fint      ldexp     randnorm  tan
  474.           ceil      floor     log       random    tanh
  475.           cos       frac      log10     ratfun
  476.           cosh      fmax      log2      round
  477. .pa
  478. .hescrnio.h                                                 scrnio.h
  479.  
  480.                     Screen Function Data File
  481.  
  482. NAME
  483.      scrnio.h
  484.  
  485. SYNOPSIS
  486.      #include <scrnio.h>
  487.  
  488. DESCRIPTION
  489.      scrnio.h  is  the data file which declares all  global  data 
  490.      necessary  for the use of these terminal display  functions.  
  491.      It contains the values of the following constants:
  492.  
  493.           ALT_SCRN[7]         alternate intensity on
  494.  
  495.           BKCURSOR[9]         cursor back
  496.  
  497.           CB4R                boolean: column before row?
  498.  
  499.           CLEARSCREEN[9]      clear screen and home cursor
  500.  
  501.           COFFSET             column value offset
  502.  
  503.           DNCURSOR[9]         cursor down
  504.  
  505.           EREOLN[7]           erase to end-of-line
  506.  
  507.           EREOPG[9]           erase to end of page
  508.  
  509.           FWCURSOR[9]         cursor forward
  510.  
  511.           HEIGHT              lines per screen
  512.  
  513.           HOMER[9]            home the cursor
  514.  
  515.           LEADIN[9]           cursor lead-in sequence
  516.  
  517.           LINDELETE[7]        delete line
  518.  
  519.           LININSERT[9]        insert line
  520.  
  521.           NORM_SCRN[7]        normal intensity on
  522.  
  523.           RCSEPARATOR[5]      row-column separator
  524.  
  525.           RCENDER[5]          lead-in termination
  526.  
  527.           ROFFSET             row value offset
  528.  
  529.           SCRNINI[9]          initialize terminal
  530.  
  531.           SCRNUNI[9]          un-initialize terminal
  532.  
  533.           SCRNWRAP            boolean: screen wrap-around?
  534.  
  535.           TERMINAL[20]        name of terminal
  536.  
  537.           UPCURSOR[9]         cursor up
  538.  
  539.           USELAST             boolean: use last screen character?
  540.  
  541.           WIDTH               columns per screen
  542.  
  543.           XLT2ASCII           boolean: translate to ASCII?
  544.  
  545. SEE ALSO
  546.      scrnio  in Section 4.
  547. .pa
  548. .hestdio.h                                                   stdio.h
  549.  
  550.         Standard Buffered Input/Output Definition Package
  551.  
  552. NAME
  553.      stdio.h 
  554.  
  555. SYNOPSIS
  556.      #include <stdio.h>
  557.  
  558.      FILE *stdin;
  559.      FILE *stdout;
  560.      FILE *stderr;
  561.  
  562. DESCRIPTION
  563.      In  the user-level frameworking scheme,  the functions  getc 
  564.      and  putc handle characters in both buffered and  unbuffered 
  565.      modes.   The  higher  level  routines  gets,  fgets,  scanf, 
  566.      fscanf,  fread, puts, fputs, printf, fprintf, fwrite all use 
  567.      getc and putc; they can be freely intermixed.
  568.  
  569.      A file with associated buffering is called a stream,  and is 
  570.      declared  to  be a pointer to a defined  type  FILE.   fopen 
  571.      creates certain descriptive data for a stream and returns  a 
  572.      pointer to designate the stream in all further transactions.  
  573.      There are three normally open streams with constant pointers 
  574.      declared  in  the  include  file  and  associated  with  the 
  575.      standard open files:
  576.  
  577.           stdin     standard input file
  578.  
  579.           stdout    standard output file
  580.  
  581.           stderr    standard error file
  582.  
  583.      STDIN,  STDOUT and STDERR are the file descriptors that read 
  584.      and write recognize as standard preopened files.
  585.  
  586.      A constant 'pointer' NULL (0) designates no stream at all.
  587.  
  588.      An integer constant EOF (-1) is returned upon end of file or 
  589.      error by integer functions that deal with streams.
  590.  
  591.      MAXSTREAM  is  the maximum number of  input/output  streams, 
  592.      and IObuffs is the file stream table.
  593.  
  594.      Any routine that uses the standard input/output package must 
  595.      include   the  header  file  <stdio.h>  of  pertinent  macro 
  596.      definitions.
  597.  
  598.      Buffered Input/Output Definitions:
  599.  
  600.            BUFSIZ        stream buffer size
  601.  
  602.  
  603.            CRINSUP       defined  when '\r' in input text must be 
  604.                          suppressed
  605.  
  606.            CROUTADD      defined when '\r' must accompany '\n' in 
  607.                          text output
  608.  
  609.            CURPOS        file position designator (lseek)
  610.  
  611.            FILEND        file end position designator (lseek)
  612.  
  613.            MAXLINE       maximum stdio input line width
  614.  
  615.            ORIGIN        beginning of file designator (lseek)
  616.  
  617.            PMODE         fopen() protection mode (for UNIX)
  618.  
  619.            SYS_EOF       system end-of-file character (if any)
  620.  
  621.            TABSTOP       stdout tabstop width
  622.  
  623.            _RDONLY       file open for read only
  624.  
  625.            _RDWRIT       file open for read/write access
  626.  
  627.            _WRONLY       file open for write only
  628.  
  629.  
  630.      File Stream _flags bit masks:
  631.  
  632.            _ALLBUF       bit set (1) when buffer is allocated
  633.  
  634.            _BUSY         bit set (1) when a FILE is open
  635.  
  636.            _DIRTY        bit set (1) when buffer is unflushed
  637.  
  638.            _EOF          bit set (1) if stream EOF is reached
  639.  
  640.            _IOERR        bit set (1) if i/o stream error
  641.  
  642.      File Stream Data Structure Definition, FILE *fp:
  643.  
  644.            BUFFER _bend     points one char past last in buffer
  645.  
  646.            BUFFER _bptr     current pointer in stream buffer
  647.  
  648.            BUFFER _buff     address of stream buffer
  649.  
  650.            unsigned _buflen length of buffer
  651.  
  652.            char _bytbuf     single byte for unbuffered streams
  653.  
  654.            TBITS _flags     open mode, error, eof, busy, etc.
  655.  
  656.            utiny _unit      file descriptor returned by open
  657.  
  658.  
  659.  
  660.      Standard I/O Macros:
  661.  
  662.            clearerr(fp)  ((fp)->_flags &= ~(_IOERR|_EOF)
  663.  
  664.            getchar()     getca(stdin)
  665.  
  666.            feof(fp)      (((fp)->_flags &_EOF) != 0)
  667.  
  668.            ferror(fp)    (((fp)->_flags &_IOERR) != 0)
  669.  
  670.            fileno(fp)    ((fp)->_unit)
  671.  
  672.            putchar(c)    putca(c, stdout)
  673.  
  674.            eputc(c)      putca(c, stderr)
  675.  
  676. SEE ALSO
  677.      open, close, read, write
  678.  
  679. DIAGNOSTICS
  680.      The value EOF is returned uniformly to indicate that a  FILE 
  681.      pointer has not been initialized with fopen,  input (output) 
  682.      has  been attempted on an output (input) stream,  or a  FILE 
  683.      pointer  designates corrupt or otherwise unintelligible FILE 
  684.      data. 
  685. .pa
  686. .hestdtyp.h                                                 stdtyp.h
  687.  
  688.                    Standard Defined-Types File
  689.  
  690. NAME
  691.      stdtyp.h 
  692.  
  693. SYNOPSIS
  694.      #include <stdtyp.h>
  695.  
  696. DESCRIPTION
  697.      Several  bugs  in C programs of an earlier  generation  were 
  698.      found  by rigorously type-defining and  consistency-checking 
  699.      such  interfaces as function  arguments,  function  returned 
  700.      values,    and   structure   definitions.    This   semantic 
  701.      readability  argument  is  the only  justification  for  the 
  702.      defined-types LBITS, BITS, TBITS, METACHAR, BOOL, and TBOOL, 
  703.      because   the  underlying  types  are  not  subject  to  any 
  704.      portability problems for their restricted usage.
  705.  
  706.      The  case  is  different  for the  types  tiny,  and  utiny.  
  707.      Portability problems (both machine and compiler) are a  main 
  708.      reason  for these distinctions.   Different versions of  the 
  709.      compiler  have  introduced  data types  for  unsigned  char, 
  710.      unsigned  short,  and  even unsigned  long.   And  different 
  711.      machines may treat the type char as signed or unsigned.   If 
  712.      programs  are written with these raw C types,  they must  be 
  713.      edited by hand before porting to another compiler that  does 
  714.      not support a new type.   However, if a set of defined-types 
  715.      is consistently used,  then the defined-type can be targeted 
  716.      to the new type when it exists,  and be targeted to an older 
  717.      base  type otherwise.   For true portability,  such defined-
  718.      types must be augmented with rvalue macros:
  719.  
  720. .uj0
  721.           TINY(n)       produces  a signed value from 8 or  more                
  722.                         bits of n.
  723.  
  724.           UTINY(n)      produces  an unsigned value from 8  bits                
  725.                         (or more) of n.
  726.  
  727.  
  728.      Pseudo Storage Classes:
  729.  
  730.           FAST           equivalent to register.
  731.  
  732.           GLOBAL         equivalent to extern.
  733.  
  734.           LOCAL          equivalent to static.
  735.  
  736.      Type definitions:
  737.  
  738.           tiny           an 8 bit (or larger) signed integer.
  739.  
  740.           utiny          an 8 bit  (or larger)  unsigned  integer 
  741.                          used for a quantity.
  742.  
  743.           TBITS          an   8  bit  (or larger)  used  for  bit 
  744.                          manipulation.
  745.  
  746.           TBOOL          an 8  bit (or larger) integer,  but used 
  747.                          for boolean.
  748.  
  749.           TEXT           an 8 bit (or larger) item used only for 
  750.                          characters.
  751.  
  752.           BOOL           integer, but used for boolean.
  753.  
  754.           LBITS          long, but only for bit manipulation.
  755.  
  756.           BITS           a  16  bit (or larger) integer only  for 
  757.                          bit manipulation.
  758.  
  759.           METACHAR       a   16    bit  (or   larger)   augmented 
  760.                          character (may be -1).
  761.  
  762.           VOID           a function that returns no value.
  763.  
  764.           STRING         a string of TEXT, (char *).
  765.  
  766.           BUFFER         a  character  array used  as  a  buffer, 
  767.                          (char *).
  768.  
  769.           ALIGN          Storage allocation word  alignment  data 
  770.                          structure.
  771.  
  772.           HEADER         Storage allocation header.
  773. .uj1
  774.  
  775.      Except   for tiny, and utiny,  defined-types are written  in 
  776.      upper case to emphasize their definition in a header file.
  777.  
  778.      This  particular header file has been adapted from the Plum-
  779.      Hall Standard (Reference 4).   This file must be  customized 
  780.      to  the intended compiler/machine environment,  as described 
  781.      in the reference and Section 5 of this manual.
  782. .he
  783. .pa o
  784.                   (Intentionally left blank)
  785. .PA
  786. .PN 1
  787. .FO                                3-#
  788.                     3. S Y S T E M   C A L L S 
  789.  
  790.  
  791. This section describes all the entries into the system assumed by 
  792. the  portable  C  library.   Most of these calls  have  an  error 
  793. return.    An  error  condition  is  indicated  by  an  otherwise 
  794. impossible  returned  value.   Almost  always  this  is  -1;  the 
  795. individual sections specify the details.  An error number is also 
  796. made  available  in the external variable errno.   errno  is  not 
  797. cleared on successful calls, so it should be tested only after an 
  798. error has occurred.
  799.  
  800. The system calls assumed are:
  801.  
  802.                          close     read
  803.                          creat     rename
  804.                          exit      sbrk
  805.                          lseek     unlink
  806.                          open      write
  807.  
  808. Source code for these functions is not contained in the  portable 
  809. library;  these  functions  expected  to be available  in  the  C 
  810. language system interface supported by the vendor.
  811. .pa
  812. .heclose                                                       close
  813.  
  814.             Close a File, Operating System Interface
  815.  
  816. NAME
  817.      close
  818.  
  819. SYNOPSIS
  820.      int close(fildes)
  821.      int fildes;
  822.  
  823. DESCRIPTION
  824.      A   file  desciptor  is  an  integer  used   in   subsequent 
  825.      invocations  of  other input-output functions on  the  file. 
  826.      Given  a  file descriptor such as returned from an  open  or 
  827.      creat,  close  closes the associated file.   A close of  all 
  828.      files  is automatic on exit,  but since there is a limit  on 
  829.      the number of open files per process, close is necessary for 
  830.      programs which deal with many files.
  831.  
  832. SEE ALSO
  833.      open, write, creat, fclose
  834.  
  835. DIAGNOSTICS
  836.      close  returns a zero if a file is closed;  EOF is  returned 
  837.      for an unknown file descriptor.
  838. .pa
  839. .hecreat                                                       creat
  840.  
  841.             Create a File, Operating System Interface
  842.  
  843. NAME
  844.      creat 
  845.  
  846. SYNOPSIS
  847.      int creat(name, mode)
  848.      STRING name;
  849.      int mode;
  850.  
  851. DESCRIPTION
  852.      creat creates a new file or prepares to rewrite an  existing 
  853.      file called name, given as the address of a null-terminating 
  854.      string.   If  the  file  did not  exist,  it  is  given  the 
  855.      prescribed mode. 
  856.  
  857.      If the file did exist,  its mode and owner remain  unchanged 
  858.      but it is truncated to zero length.
  859.  
  860.      The file is also opened for writing, and its file descriptor 
  861.      is returned.
  862.  
  863.      The  mode  given is arbitrary;  it need not  allow  writing.  
  864.      This  feature  is  system-dependent,   originally  used   by 
  865.      programs  which  deal with temporary files of  fixed  names.  
  866.      The creation was done as a mode that forbids writing.   Then 
  867.      if a second instance of the program were to attempt a creat, 
  868.      an  error is returned and the program knows that the name is 
  869.      unusable  for  the moment.   However,  this feature  is  not 
  870.      guaranteed in the portable library, and should not be relied 
  871.      upon.
  872.  
  873. SEE ALSO
  874.      open, write, close, stdio.h
  875.  
  876. DIAGNOSTICS
  877.      For creat,  the value EOF is returned if: a needed directory 
  878.      is not searchable; the file does not exist and the directory 
  879.      in which it is to be created is not writable;  the file does 
  880.      exist and is unwritable;  the file is a directory; there are 
  881.      already too many files open.
  882. .pa
  883. .heexit                                                         exit
  884.  
  885.                         Terminate Process
  886.  
  887. NAME
  888.      exit, _exit 
  889.  
  890. SYNOPSIS
  891.      VOID exit(status)
  892.      int status;
  893.  
  894.      VOID _exit(status)
  895.      int status;
  896.  
  897. DESCRIPTION
  898.      exit is the normal means of terminating a process.   exit is 
  899.      supposed to close all the process's files;  however,  it may 
  900.      not  close buffered streams of the  portable  library.   For 
  901.      this  purpose,  the  portable function fclose is  available. 
  902.      status may be available to whatever process called this one, 
  903.      depending on the system,   so the success or failure of  the 
  904.      program  can be tested by another program that uses this one 
  905.      as a sub-process.
  906.  
  907.      This call can never return.
  908.  
  909.      The  C  function exit may cause cleanup actions  before  the 
  910.      final  'sys  exit'.   The  function  _exit  circumvents  all 
  911.      cleanup.
  912.  
  913. SEE ALSO
  914.      fclose, redirbuf
  915. .pa 
  916. .helseek                                                       lseek
  917.  
  918.                      Move Read/Write Pointer
  919.  
  920. NAME
  921.      lseek 
  922.  
  923. SYNOPSIS
  924.      long lseek(fildes, offset, whence)
  925.      int fildes;
  926.      long offset;
  927.      int whence;
  928.  
  929. DESCRIPTION
  930.      The  file  descriptor refers to a file open for  reading  or 
  931.      writing.  The read (resp. write) pointer for the file is set 
  932.      as follows:
  933.  
  934.            If whence is ORIGIN (0),  the pointer is set to offset 
  935.            bytes.
  936.  
  937.            If  whence is CURPOS (1),  the pointer is set  to  its 
  938.            current location plus offset.
  939.  
  940.            If  whence  is FILEND (2),  the pointer is set to  the 
  941.            size of the file plus offset.
  942.  
  943.      The returned value is the resulting pointer location.
  944.  
  945.      Seeking far beyond the end of a file,  then writing, creates 
  946.      a gap or hole, which occupies no physical space and reads as 
  947.      zeros.
  948.  
  949. SEE ALSO
  950.      open, creat, fseek, stdio.h
  951.  
  952. DIAGNOSTICS
  953.      EOF is returned for an undefined file descriptor, or seek to 
  954.      a position before the beginning of file.
  955. .pa
  956. .heopen                                                         open
  957.  
  958.                    Open for Reading or Writing
  959.  
  960. NAME
  961.      open 
  962.  
  963. SYNOPSIS
  964.      int open(name, flag, mode)
  965.      STRING name;
  966.      int flag, mode;
  967.  
  968. DESCRIPTION
  969.      open  opens the file name for reading (if flag  is  _RDONLY, 
  970.      0),  writing (if flag is _WRONLY, 1) or for both reading and 
  971.      writing (if flag is _RDWRIT,  2).   name is the address of a 
  972.      string   of  ASCII  characters  representing  the  filename, 
  973.      terminated by a NULL character.
  974.  
  975.      The  file  is  positioned at the beginning  (byte  0).   The 
  976.      returned  file descriptor must be used for subsequent  calls 
  977.      for other input-output functions on the file.
  978.  
  979.      The mode is arbitrary,  and is unused for the flag values of 
  980.      the  portable library.   The presence or absence of the mode 
  981.      argument may require modules calling the open function to be 
  982.      modified  to  conform  with the  requirements  of  the  host 
  983.      computer.
  984.  
  985. SEE ALSO
  986.      creat, read, write, close, fopen, stdio.h
  987.  
  988. DIAGNOSTICS
  989.      The value EOF is returned if the file does not exist, if one 
  990.      of   the   necessary  directories  does  not  exist  or   is 
  991.      unreadable, if the file is not readable (resp. writable), or 
  992.      if too many files are open.
  993. .pa
  994. .heread                                                         read
  995.  
  996.                          Read from File
  997.  
  998. NAME
  999.      read 
  1000.  
  1001. SYNOPSIS
  1002.      int read(fildes, buffer, nbytes)
  1003.      int fildes, nbytes;
  1004.      BUFFER buffer;
  1005.  
  1006. DESCRIPTION
  1007.      A   file  descriptor  is  the  int  value  returned  from  a 
  1008.      successful open or creat.  buffer is the location of  nbytes 
  1009.      contiguous bytes into which the input will be placed.  It is 
  1010.      not  guaranteed  that  all nbytes bytes will  be  read;  for 
  1011.      example, if the file refers to a typewriter at most one line 
  1012.      will be returned.   In any event,  the number of  characters 
  1013.      read is returned.
  1014.  
  1015.      If  the  returned value is zero,  then end-of-file has  been 
  1016.      reached.
  1017.  
  1018. SEE ALSO
  1019.      open, creat
  1020.  
  1021. DIAGNOSTICS
  1022.      As mentioned,  NULL (0) is returned when the end of the file 
  1023.      has  been reached.   If the read was otherwise  unsuccessful 
  1024.      the  return value is EOF.   Many conditions can generate  an 
  1025.      error: physical I/O errors, bad buffer address, preposterous 
  1026.      nbytes, file descriptor not that of an input file. 
  1027.  
  1028. BUGS
  1029.      Some  systems may contain internal buffering to make use  of 
  1030.      terminal  line editing features of some  operating  systems.  
  1031.      Therefore,  read(0,  buffer, 1) may not respond properly for 
  1032.      character-by-character inputs.
  1033. .pa
  1034. .herename                                                     rename
  1035.  
  1036.                           Rename a File
  1037.  
  1038. NAME
  1039.      rename
  1040.  
  1041. SYNOPSIS
  1042.      int rename(old, new)
  1043.      STRING old, new;
  1044.  
  1045. DESCRIPTION
  1046.      rename changes the name of a file from old to new.
  1047.  
  1048. DIAGNOSTICS
  1049.      rename returns the value NULL if successful, and EOF is not.
  1050. .pa
  1051. .hesbrk                                                         sbrk
  1052.  
  1053.                      Change Core Allocation
  1054.  
  1055. NAME
  1056.      sbrk 
  1057.  
  1058. SYNOPSIS
  1059.      STRING sbrk(incr)
  1060.      int incr;
  1061.  
  1062. DESCRIPTION
  1063.      In  sbrk,  incr more bytes are added to the  program's  data 
  1064.      space  and a pointer to the start of the lowest location not 
  1065.      used by program (called the break) is returned.
  1066.  
  1067. SEE ALSO
  1068.      malloc, free
  1069.  
  1070. DIAGNOSTICS
  1071.      An  EOF (-1) is returned if the program requests more memory 
  1072.      than the system limit or if other operating system  internal 
  1073.      contraints are violated.
  1074.  
  1075. BUGS
  1076.      Setting  the break in the range 0177701 to 0177777  (on  the 
  1077.      PDP11) is the same as setting it to zero.   
  1078. .pa
  1079. .heunlink                                                     unlink
  1080.  
  1081.                      Remove Directory Entry
  1082.  
  1083. NAME
  1084.      unlink 
  1085.  
  1086. SYNOPSIS
  1087.      int unlink(name)
  1088.      STRING name;
  1089.  
  1090. DESCRIPTION
  1091.      name points to a null-terminated string.  unlink removes the 
  1092.      entry  for  the file identified by name from its  directory.  
  1093.      If this entry was the last link to the file, the contents of 
  1094.      the file are freed and the file is destroyed.   If, however, 
  1095.      the file was open in any process,  the actual destruction is 
  1096.      delayed until it is closed,  even though the directory entry 
  1097.      has disappeared.
  1098.  
  1099. DIAGNOSTICS
  1100.      NULL  (0) is normally returned;  EOF indicates that the file 
  1101.      does  not exist,  that its directory cannot be  written,  or 
  1102.      that the file contains pure procedure text that is currently 
  1103.      in  use.   Write  permission  is not required  on  the  file 
  1104.      itself.   It  is also illegal to unlink a directory  (except 
  1105.      for the super-user, in UNIX).
  1106.  
  1107. .pa
  1108. .hewrite                                                       write
  1109.  
  1110.                          Write on a File
  1111.  
  1112.  
  1113. NAME
  1114.      write 
  1115.  
  1116. SYNOPSIS
  1117.      int write(fildes, buffer, nbytes)
  1118.      int fildes, nbytes;
  1119.      BUFFER buffer;
  1120.  
  1121. DESCRIPTION
  1122.      A  file descriptor is an integer returned from a  successful 
  1123.      open or creat.
  1124.  
  1125.      buffer is the address of nbytes contiguous bytes,  which are 
  1126.      written  on  the  output file.   The  number  of  characters 
  1127.      actually written is returned.   It should be regarded as  an 
  1128.      error if the returned value is not the same as nbytes.
  1129.  
  1130.      Writes  of  a  certain size may be more  efficient  on  some 
  1131.      machines, depending on implementation particulars.
  1132.  
  1133. SEE ALSO
  1134.      creat, open
  1135.  
  1136. DIAGNOSTICS
  1137.      Returns  EOF on error:  bad descriptor,  buffer address,  or 
  1138.      count; physical I/O errors.
  1139. .he
  1140. .pa o
  1141.                   (Intentionally left blank)
  1142. .PA
  1143. .PN 1
  1144. .FO                                4-#
  1145.                  4. F U N C T I O N   L I B R A R Y 
  1146.  
  1147.  
  1148. This  chapter  describes  functions contained in the  portable  C 
  1149. function library.
  1150.  
  1151. Functions in the math library may return conventional values when 
  1152. the  function  is undefined for the given arguments or  when  the 
  1153. value is not representable.  In these cases the external variable 
  1154. errno is set to the value EDOM or ERANGE.  The values of EDOM and 
  1155. ERANGE are defined in the include file <errno.h>.
  1156.  
  1157. Many  entries  contain  more  than  one  function;  however,  all 
  1158. function names (and short definition, if different from name) are 
  1159. included in the index for easy access.
  1160.  
  1161. Because  of  file space limitations in  some  host  systems,  the 
  1162. conglomeration  of  functions into files is expected to be  host-
  1163. dependent;  and,  therefore,  not covered here.  A list of source 
  1164. files and the functions they contain is given in Section 5.
  1165. .pa
  1166. .heabs                                                           abs
  1167.  
  1168.                          Absolute Values
  1169.  
  1170. NAME                  
  1171.      abs, fabs, labs 
  1172.                       
  1173. SYNOPSIS              
  1174.      int abs(i)           
  1175.      int i;           
  1176.  
  1177.      double fabs(x)
  1178.      double x;
  1179.                       
  1180.      long labs(n)          
  1181.      long n;          
  1182.                       
  1183. DESCRIPTION           
  1184.      abs  is  a  function  returning the absolute  value  of  its 
  1185.      integer operand.
  1186.  
  1187.      ABS  is the macro in header file defs.h,  which performs the 
  1188.      same  operation  as  the function abs,  but  may  have  side 
  1189.      effects.  ABS works for all numeric types.
  1190.  
  1191.      fabs returns the absolute value |x|.
  1192.  
  1193.      labs  returns  the long integer absolute value of  its  long 
  1194.      operand, n.
  1195.  
  1196. BUGS
  1197.      You  get  what  the hardware gives on the  largest  negative 
  1198.      integer.
  1199. .pa
  1200. allot                                                       allot
  1201.  
  1202.                     Memory Allocation Package
  1203.  
  1204. NAME
  1205.      allot, liberate
  1206.  
  1207. SYNOPSIS
  1208.      STRING allot(nbytes)
  1209.      unsigned nbytes;
  1210.  
  1211.      VOID liberate(ptr, nbytes)
  1212.      STRING ptr;
  1213.      unsigned nbytes;
  1214.  
  1215. DESCRIPTION
  1216.      allot and liberate provide a simple,  general-purpose memory 
  1217.      allocation package.   allot returns a pointer to a block  of 
  1218.      at  least nbytes bytes.   The arguments of liberate define a 
  1219.      block  to  be made available for  further  allocation.   The 
  1220.      liberated block need not have been previously allotted.
  1221.  
  1222.      Needless  to say,  grave disorder will result if  the  space 
  1223.      assigned  by  allot  is overrun or if some  random  ptr   or 
  1224.      oversize nbytes is handed to liberate.
  1225.  
  1226.      allot  allocates  the first big-enough contiguous  reach  of 
  1227.      free  space  found in a circular search from the last  block 
  1228.      allocated  or freed,  coalescing adjacent free blocks as  it 
  1229.      searches.   It calls sbrk to get more memory from the system 
  1230.      when there is no suitable space already free.
  1231.  
  1232.      allot  and  liberate work much the same as malloc and  free. 
  1233.      The differences are that malloc and free operate with blocks 
  1234.      that  contain an overhead structure,  and freed blocks  must 
  1235.      have  been  previously allocated,  whereas  allotted  blocks 
  1236.      contain no such overhead, and liberated blocks may be freely 
  1237.      added  to  the available store.   Blocks  are  allotted  and 
  1238.      liberated in units of size sizeof(HEADER) bytes.
  1239.  
  1240. DIAGNOSTICS
  1241.      allot  returns a NULL pointer (0) if there is  no  available 
  1242.      memory  or  if the operating system has detected  corruption 
  1243.      outside the allotted area.
  1244.  
  1245. SEE ALSO
  1246.      malloc, free
  1247. .pa
  1248. .heatof                                                         atof
  1249.  
  1250.                     ASCII/Numeric Conversion
  1251.  
  1252. NAME
  1253.      astof,  astoi,  astol,  atof, atoi, atol, ftoa, itoa, itoab, 
  1254.      ltoa, ltoab, tobase, utoa
  1255.  
  1256. SYNOPSIS
  1257.      STRING astof(s, val)
  1258.      STRING s;
  1259.      double *val;
  1260.      
  1261.      STRING astoi(s, val)
  1262.      STRING s;
  1263.      int *val;
  1264.  
  1265.      STRING astol(s, val)
  1266.      STRING s;
  1267.      long *val;
  1268.  
  1269.      double atof(s)
  1270.      STRING s;
  1271.      
  1272.      int atoi(s)
  1273.      STRING s;
  1274.  
  1275.      long atol(s)
  1276.      STRING s;
  1277.  
  1278.      STRING ftoa(s, x, pr, mode)
  1279.      STRING s;
  1280.      double x;
  1281.      int pr;
  1282.      char mode;
  1283.  
  1284.      STRING itoa(s, n, w)
  1285.      STRING s;
  1286.      int n, w;
  1287.  
  1288.      STRING itoab(s, n, w, b)
  1289.      STRING s;
  1290.      int n, w, b;
  1291.  
  1292.      STRING ltoa(s, n, w)
  1293.      STRING s;
  1294.      long n;
  1295.      int w;
  1296.  
  1297.      STRING ltoab(s, n, w, b)
  1298.      STRING s;
  1299.      long n;
  1300.      int w, b;
  1301.  
  1302.  
  1303.  
  1304.      METACHAR tobase(ch, base)
  1305.      char ch;
  1306.      int base;
  1307.  
  1308.      STRING utoa(s, n, w)
  1309.      STRING s;
  1310.      unsigned n;
  1311.      int w;
  1312.  
  1313. DESCRIPTION
  1314.      astof,  astoi  and astol convert a string pointed to by s to 
  1315.      floating,  integer,  and  long  integer  val  representation 
  1316.      respectively.   The  first unrecognized character  ends  the 
  1317.      string.   They  operate  in the same way as atof,  atoi  and 
  1318.      atol,  except that they store the value in val, and return a 
  1319.      pointer to the next unused character.
  1320.  
  1321.      atof,  atoi,  and atol functions convert a string pointed to 
  1322.      by s to floating,  integer, and long integer representation, 
  1323.      respectively.   The  first unrecognized character  ends  the 
  1324.      conversion.
  1325.  
  1326.      atof recognizes an optional string of tabs and spaces,  then 
  1327.      an  optional  sign,  then  a  string  of  digits  optionally 
  1328.      containing  a  decimal point,  then an optional 'e'  or  'E' 
  1329.      followed by an optionally signed integer.
  1330.  
  1331.      atoi  and  atol  recognize an optional string  of  tabs  and 
  1332.      spaces,  then an optional sign, then a string of digits.  If 
  1333.      the string begins in '0x',  then the number is assumed to be 
  1334.      hexadecimal;  otherwise,  if  the leading digit is '0',  the 
  1335.      string is interpreted as an octal.
  1336.  
  1337.      ftoa  converts x to an ASCII string s with precision  pr  in 
  1338.      mode  'e',  'f', or 'g' format.   This function returns  the 
  1339.      pointer to s.   The mode argument may also be 0,  1 or 2  to 
  1340.      designate 'e', 'f', or 'g', respectively.
  1341.  
  1342.      itoa converts an integer to ASCII.   It returns a pointer to 
  1343.      s, which contains the ASCII value of n to minimum width |w|, 
  1344.      0-filled  if w<0,  else space-filled.   This function  is  a 
  1345.      modified  version  of itoa() found in Kernighan and  Ritchie 
  1346.      (see Reference 2,  pp.  60), with modifications as suggested 
  1347.      in  exercises  3-3 and 3-5,  and with  returned  pointer  to 
  1348.      result string.
  1349.  
  1350.      itoab  converts  an  integer n to a  minimum  of  |w|  ascii 
  1351.      characters,  base  b.   It  returns a pointer  to  s,  which 
  1352.      contains  the  ASCII value.   If w is less than zero,  s  is 
  1353.      zero-filled; otherwise, it is space-filled.
  1354.  
  1355.      ltoa  converts a long n to a minimum of |w| ASCII characters 
  1356.      (0-filled if w < 0,  and space-filled otherwise),  and  puts 
  1357.      them  in  s,  returning the pointer to s.   This is  also  a 
  1358.      modified  version of itoa() from Kernigan and Ritchie,  with 
  1359.      modifications as suggested in exercises 3-3 and 3-5, for use 
  1360.      with the long data type. (see Reference 2, pp. 60)
  1361.  
  1362.      ltoab  converts long n to a minimum of w  ascii  characters, 
  1363.      base b, and puts the ASCII in s, returning a pointer to s.
  1364.  
  1365.      tobase  returns the value of character ch to base  base,  if 
  1366.      valid, or EOF if not.
  1367.  
  1368.      utoa returns a pointer to the string s, which contains ASCII 
  1369.      value  of unsigned n,  base 10,  with minimum width |w|  (0-
  1370.      filled if w < 0, and space-filled otherwise).  This function 
  1371.      is  another  modified version of itoa() found in K & R  (see 
  1372.      Reference 2,  pp.  60),  with modifications as suggested  in 
  1373.      exercises  3-4 and 3-5,  and with returned pointer to result 
  1374.      string.
  1375.  
  1376. SEE ALSO
  1377.      scanf
  1378.  
  1379. BUGS
  1380.      There are no provisions for overflow.
  1381. .pa
  1382. .hebitcount                                                 bitcount
  1383.  
  1384.                      Count Bits in Argument
  1385.  
  1386. NAME
  1387.      bitcount 
  1388.  
  1389. SYNOPSIS
  1390.      int bitcount(i)
  1391.      BITS i;
  1392.  
  1393. DESCRIPTION
  1394.      bitcount  is a K & R function (Reference 2,  page 47)  which 
  1395.      counts and returns the number of 1-bits in i.
  1396. .pa
  1397. .heclearerr                                                 clearerr
  1398.  
  1399.                      Stream Status Inquiries
  1400.  
  1401. NAME
  1402.      clearerr, feof, ferror, fileno 
  1403.  
  1404. SYNOPSIS
  1405.      #include <stdio.h>
  1406.  
  1407.      VOID clearerr(stream)
  1408.      FILE *stream;
  1409.  
  1410.      BOOL feof(stream)
  1411.      FILE *stream;
  1412.  
  1413.      BOOL ferror(stream)
  1414.      FILE *stream;
  1415.  
  1416.      int fileno(stream)
  1417.      FILE *stream;
  1418.  
  1419. DESCRIPTION
  1420.      clearerr  resets  (sets  to 0) the error indication  on  the 
  1421.      named stream.
  1422.  
  1423.      feof returns non-NULL when end of file is read on the  named 
  1424.      input stream, otherwise it returns NULL.
  1425.  
  1426.      ferror  returns  non-NULL if an error has occurred  on  FILE 
  1427.      stream; otherwise, it returns NULL.
  1428.  
  1429.      fileno  returns the integer file descriptor associated  with 
  1430.      the stream; see open.
  1431.  
  1432.      In  UNIX,  these functions are implemented as  macros;  they 
  1433.      cannot  be  redeclared.   Here,  however,  they  are  normal 
  1434.      functions  and  do  not have the possible  side  effects  of 
  1435.      macros.   
  1436.  
  1437.      They  do  have  corresponding  macros,   found  in  stdio.h: 
  1438.      CLEARERR, FEOF, FERROR, and FILENO.
  1439.  
  1440. SEE ALSO
  1441.      fopen, open
  1442.  
  1443. .pa
  1444. .heerf                                                           erf
  1445.  
  1446.               Gaussian Error Functions and Inverses
  1447.  
  1448. NAME
  1449.      erf, erfc, inverf, inverfc 
  1450.  
  1451. SYNOPSIS
  1452.      double erf(x)
  1453.      double x;
  1454.  
  1455.      double erfc(x)
  1456.      double x;
  1457.  
  1458.      double inverf(x)
  1459.      double x;
  1460.  
  1461.      double inverfc(x)
  1462.      double x;
  1463.  
  1464. DESCRIPTION
  1465.      erf returns the error function of x,  as defined in Handbook 
  1466.      of Mathematical Functions (See Reference 3, pp. 297).
  1467.  
  1468.      erfc   returns  the  complimentary  error  function  of   x, 
  1469.      1-erf(x).
  1470.  
  1471.      Coefficients  for the above functions are  from  Schonfelder 
  1472.      (see Reference 7).
  1473.  
  1474.      inverf returns the inverse of the error function, erf.  This 
  1475.      routine uses the approximations given in "Rational Chebyshev 
  1476.      Approximations   for  the  Inverse  Error  Function",   (see 
  1477.      Reference 8, pp. 827-830)
  1478.  
  1479.      inverfc  returns  the  inverse of  the  complementary  error 
  1480.      function, erfc.
  1481.  
  1482. DIAGNOSTICS
  1483.      In inverf,  if |x| > 1.0, errno is set to EDOM.  In inverfc, 
  1484.      if |x| < 0 or > 2,  errno is set to EDOM,  and if x is zero, 
  1485.      it is set to ERANGE. In each  of  these  cases, INFINITY  or 
  1486.      -INFINITY   is   returned  for  positive  or   negative   x, 
  1487.      respectively;
  1488. .pa
  1489. .heexp                                                           exp
  1490.  
  1491.                      Mathematical Functions
  1492.  
  1493. NAME
  1494.      exp,  log,  log10,  log2,  pow,  sqrt,  cbrt 
  1495.  
  1496. SYNOPSIS
  1497.      double exp(x)
  1498.      double x;
  1499.  
  1500.      double log(x)
  1501.      double x;
  1502.  
  1503.      double log10(x)
  1504.      double x;
  1505.  
  1506.      double log2(x)
  1507.      double x;
  1508.  
  1509.      double pow(x,y)
  1510.      double x, y;
  1511.  
  1512.      double sqrt(x)
  1513.      double x;
  1514.  
  1515.      double cbrt(x)
  1516.      double x;
  1517.  
  1518. DESCRIPTION
  1519.      All  functions above except cbrt were programmed  using  the 
  1520.      algorithms in Coty and Waite (Reference 5).
  1521.  
  1522.      exp  returns  the  exponential  function  of  x,   ex,  (see 
  1523.      Reference 5, pp. 60-83).
  1524.  
  1525.      log returns the natural logarithm of x (see Reference 5, pp. 
  1526.      35-59).
  1527.  
  1528.      log10  returns  the  common (base 10)  logarithm,  and  log2 
  1529.      returns the binary logarithm (base 2) of x.
  1530.  
  1531.      pow returns x raised to the power of y, where x > 0, xy (see 
  1532.      Reference 5, pp. 84-124).
  1533.  
  1534.      sqrt returns the square root of x, for x > 0 (see Reference 5, 
  1535.      pp. 17-34).
  1536.  
  1537.      cbrt returns the cube root of x  (see Reference 6).
  1538.  
  1539. SEE ALSO
  1540.      hypot, sinh
  1541.  
  1542. DIAGNOSTICS
  1543.      exp  and  pow return INFINITY when the correct  value  would 
  1544.      overflow;   errno  is set to ERANGE.   pow returns zero  and 
  1545.      sets  errno to EDOM when the second argument is negative and 
  1546.      non-integral, and also when both arguments are zero.
  1547.      
  1548.      log returns zero when x is zero or negative;   errno is  set 
  1549.      to EDOM.
  1550.  
  1551.      sqrt returns zero when x is negative; errno is set to EDOM.
  1552. .pa
  1553. .hefclose                                                     fclose
  1554.  
  1555.                      Close or Flush a Stream
  1556.  
  1557. NAME
  1558.      fclose, fflush, flush
  1559.  
  1560. SYNOPSIS
  1561.      #include <stdio.h>
  1562.  
  1563.      int fclose(stream)
  1564.      FILE *stream;
  1565.  
  1566.      int fflush(stream)
  1567.      FILE *stream;
  1568.  
  1569.      int flush(stream, c)
  1570.      FILE *stream;
  1571.      int c;
  1572.  
  1573. DESCRIPTION
  1574.      fclose  causes  any  buffers  for the  named  stream  to  be 
  1575.      emptied,  and  the file to be closed.   Buffers allocated by 
  1576.      the standard input/output system are freed.
  1577.  
  1578.      fclose is performed automatically upon calling exit,  on all 
  1579.      open files.  
  1580.  
  1581.      fflush causes any buffered data for the named output  stream 
  1582.      to be written to that file.  The stream remains open.
  1583.  
  1584.      flush writes any buffered characters onto FILE stream;  then 
  1585.      if c isn't EOF,  it puts it in the buffer.
  1586.  
  1587. SEE ALSO
  1588.      close, fopen
  1589.  
  1590. DIAGNOSTICS
  1591.      These  routines return EOF if stream is not associated  with 
  1592.      an output file, or if buffered data cannot be transferred to 
  1593.      that file.  NULL is returned on success.
  1594. .pa
  1595. .hefint                                                         fint
  1596.  
  1597.  Absolute Value, Rounding, Integer and Fractional Part Functions
  1598.  
  1599. NAME
  1600.      fint, frac, chrstc, floor, ceil, round
  1601.  
  1602. SYNOPSIS
  1603.      double fint(x)
  1604.      double x;
  1605.  
  1606.      double frac(x)
  1607.      double x;
  1608.  
  1609.      int chrstc(x)
  1610.      double x;
  1611.  
  1612.      double floor(x)
  1613.      double x;
  1614.  
  1615.      double ceil(x)
  1616.      double x;
  1617.  
  1618.      double round(x)
  1619.      double x;
  1620.  
  1621. DESCRIPTION
  1622.      fint returns the integer part of x as a double.
  1623.  
  1624.      frac returns the fractional part of x, i.e. x - fint(x).
  1625.  
  1626.      chrstc  returns the characteristic (2's exponent) of  double 
  1627.      x.  The mantissa is in [.5,1).
  1628.  
  1629.      floor returns the largest integer not greater than x.
  1630.  
  1631.      ceil returns the smallest integer not less than x.
  1632.  
  1633.      round returns x rounded to the nearest integer in magnitude.
  1634. .pa
  1635. .hefopen                                                       fopen
  1636.  
  1637.                           Open a Stream
  1638.  
  1639. NAME
  1640.      fopen 
  1641.  
  1642. SYNOPSIS
  1643.      #include <stdio.h>
  1644.  
  1645.      FILE *fopen(filename, type)
  1646.      STRING filename, type;
  1647.  
  1648. DESCRIPTION
  1649.      fopen  opens  the  file named by filename and  associates  a 
  1650.      stream  with  it.   fopen returns a pointer to  be  used  to 
  1651.      identify the stream in subsequent operations.
  1652.  
  1653.      type  is  a  character string having one  of  the  following 
  1654.      values:
  1655.  
  1656.      "r"   open for reading
  1657.  
  1658.      "w"   create for writing
  1659.  
  1660.      "a"   append: open for writing at end of file, or create for 
  1661.            writing
  1662.  
  1663.      "r+"  open  for reading  and writing.   same a "r"  but  the 
  1664.            device or file may also be written to.
  1665.  
  1666.      "w+"  open for reading  and writing.   same as "w"  but  the 
  1667.            device or file may also be read.
  1668.  
  1669.      "a+"  open for append and read.   same as "a" but the device 
  1670.            or file may also be read.
  1671.  
  1672. SEE ALSO
  1673.      open, fclose
  1674.  
  1675. DIAGNOSTICS
  1676.      fopen  returns  the  pointer  NULL  if  filename  cannot  be 
  1677.      accessed.
  1678.  
  1679. .pa
  1680. .hefread                                                       fread
  1681.  
  1682.                       Buffered Input/Output
  1683.  
  1684. NAME
  1685.      fread, fwrite 
  1686.  
  1687. SYNOPSIS
  1688.      #include <stdio.h>
  1689.  
  1690.      int fread(ptr, ptrsize, nitems, stream)
  1691.      BUFFER ptr;
  1692.      int ptrsize, nitems;
  1693.      FILE *stream;
  1694.  
  1695.      int fwrite(ptr, ptrsize, nitems, stream)
  1696.      BUFFER ptr;
  1697.      int ptrsize, nitems;
  1698.      FILE *stream;
  1699.  
  1700. DESCRIPTION
  1701.      fread reads,  into a block beginning at ptr, nitems items of 
  1702.      ptrsize bytes from the named input stream.   It returns  the 
  1703.      number of items actually read.
  1704.  
  1705.      fwrite appends at most nitems items of ptrsize bytes of type 
  1706.      *ptr  to  the FILE stream.   It returns the number of  items 
  1707.      actually written.
  1708.      
  1709. SEE ALSO
  1710.      read, write, fopen, getc, putc, gets, puts, printf, scanf
  1711.  
  1712. DIAGNOSTICS
  1713.      fread and fwrite return NULL upon end of file or error.
  1714. .pa
  1715. .hefrexp                                                       frexp
  1716.  
  1717.                  Mantissa and Exponent Functions
  1718.  
  1719. NAME
  1720.      frexp, ldexp, modf 
  1721.  
  1722. SYNOPSIS
  1723.      double frexp(value, eptr)
  1724.      double value;
  1725.      int *eptr;
  1726.  
  1727.      double ldexp(value, exp)
  1728.      double value;
  1729.      int exp;
  1730.  
  1731.      double modf(value, iptr)
  1732.      double value, *iptr;
  1733.  
  1734. DESCRIPTION
  1735.      frexp  returns  the mantissa of a double value as  a  double 
  1736.      quantity,  x,  of  magnitude in the interval [0.5,  1),  and 
  1737.      stores  an  integer n such that value = x  *  2n  indirectly 
  1738.      through eptr.
  1739.  
  1740.      ldexp returns the quantity value*2exp.
  1741.  
  1742.      modf   returns   the  fractional  part   of   value,   i.e., 
  1743.      frac(value),  and stores the integer part indirectly through 
  1744.      iptr, i.e., *iptr = fint(value).
  1745.  
  1746. BUGS
  1747.      The definition of modf appears to be somewhat different than 
  1748.      that given in Ref. 1 for negative value arguments.
  1749.  
  1750. SEE ALSO
  1751.      frac, fint
  1752. .pa
  1753. .hefseek                                                       fseek
  1754.  
  1755.                        Reposition a Stream
  1756.  
  1757. NAME
  1758.      fseek, ftell, rewind 
  1759.  
  1760. SYNOPSIS
  1761.      #include <stdio.h>
  1762.  
  1763.      int fseek(stream, offset, whence)
  1764.      FILE *stream;
  1765.      long offset;
  1766.      int whence;
  1767.  
  1768.      long ftell(stream)
  1769.      FILE *stream;
  1770.  
  1771.      int rewind(stream)
  1772.      FILE *stream;
  1773.  
  1774. DESCRIPTION
  1775.      fseek  sets  the  position  of  the  next  input  or  output 
  1776.      operation on the stream.   The new position is at the signed 
  1777.      distance  offset  bytes  from  the  beginning,  the  current 
  1778.      position,  or  the end of the file,  according as whence has 
  1779.      the value ORIGIN (0), CURPOS (1), or FILEND (2).
  1780.  
  1781.      fseek undoes any effects of ungetc.
  1782.  
  1783.      ftell  returns  the  current value of the  offset  in  bytes 
  1784.      relative  to  the  ORIGIN of the FILE  stream,  measured  in 
  1785.      bytes.
  1786.  
  1787.      On  some  systems,  ftell may be the only foolproof  way  to 
  1788.      obtain an offset for fseek.
  1789.  
  1790.      rewind(stream) is equivalent to fseek(stream,  OL,  ORIGIN).  
  1791.      It sets the FILE fp to the ORIGIN.
  1792.  
  1793. SEE ALSO
  1794.      lseek, fopen
  1795.      
  1796. DIAGNOSTICS
  1797.      fseek and rewind return EOF for improper seeks.
  1798. .pa
  1799. .hegetbuf                                                     getbuf
  1800.  
  1801.                           Get a Buffer
  1802.  
  1803. NAME
  1804.      getbuf
  1805.  
  1806. SYNOPSIS
  1807.      VOID getbuf(fp)
  1808.      FAST FILE *fp;
  1809.  
  1810. DESCRIPTION
  1811.      getbuf  gets a buffer either from allot or else it uses  the 
  1812.      bytbuf, attaching to the FILE fp.
  1813. .pa
  1814. .hegetc                                                         getc
  1815.  
  1816.                 Get Character or Word from Stream
  1817.  
  1818. NAME
  1819.      getc, getca, getchar, getf, geti, getl
  1820.  
  1821. SYNOPSIS
  1822.      #include <stdio.h>
  1823.  
  1824.      int getc(stream)
  1825.      FILE *stream;
  1826.  
  1827.      int getca(stream)
  1828.      FILE *stream;
  1829.  
  1830.      int getchar()
  1831.  
  1832.      double getf(prompt, check, low, high)
  1833.      STRING prompt;
  1834.      BOOL check;
  1835.      double low, high;
  1836.  
  1837.      int geti(prompt, check, low, high)
  1838.      STRING prompt;
  1839.      BOOL check;
  1840.      int low, high;
  1841.  
  1842.      long getl(prompt, check, low, high)
  1843.      STRING prompt;
  1844.      BOOL check;
  1845.      long low, high;
  1846.  
  1847. DESCRIPTION
  1848.      getc returns the next character from the named input stream.
  1849.  
  1850.      getca is the same as getc, except that '\r' characters input 
  1851.      from  the  stream  are suppressed (when  compiled  with  the 
  1852.      CRINSUP switch in stdio.h TRUE).
  1853.  
  1854.      getchar()  is identical to getca(stdin).   stdio.h  contains 
  1855.      the macro, GETCHAR which is the same as this function.
  1856.  
  1857.      getf  prints  prompt  on stdout,  then reads  from  stdin  a 
  1858.      double, which it returns.  If check is TRUE, doubles outside 
  1859.      of the low - high bounds will not be accepted.
  1860.  
  1861.      geti and getl work the same as getf, except that they return 
  1862.      an integer and a long, respectively.
  1863.  
  1864.      The standard input stream stdin is normally buffered if  and 
  1865.      only  if the input refers to a device other than a terminal.  
  1866.      When an input stream is unbuffered,  information is returned 
  1867.      from  getc as soon as it is written;   when it is  buffered, 
  1868.      many characters are saved up and returned by getc only after 
  1869.      a  newline  is  encountered.    To  ensure  portability   of 
  1870.      programs, always use setbuf to set the proper buffering mode 
  1871.      at the beginning.
  1872.  
  1873. SEE ALSO
  1874.      fopen, putc, gets, scanf, fread, ungetc, setbuf
  1875.  
  1876. DIAGNOSTICS
  1877.      These  functions  return the integer constant EOF at end  of 
  1878.      file or upon read error.
  1879.  
  1880. BUGS
  1881.      Some  systems may contain internal buffering to make use  of 
  1882.      terminal  line  editing features of some operating  systems, 
  1883.      even  when unbuffered input is desired.   Therefore  getchar 
  1884.      may not respond properly for character-by-character inputs.
  1885. .pa
  1886. .hegets                                                         gets
  1887.  
  1888.                    Get a String from a Stream
  1889.  
  1890. NAME
  1891.      gets, getns, fgets 
  1892.  
  1893. SYNOPSIS
  1894.      #include <stdio.h>
  1895.  
  1896.      STRING gets(s)
  1897.      STRING s;
  1898.  
  1899.      STRING getns(p, s, n)
  1900.      STRING p, s;
  1901.      int n;
  1902.  
  1903.      STRING fgets(s, n, stream)
  1904.      STRING s;
  1905.      FILE *stream;
  1906.      int n;
  1907.  
  1908. DESCRIPTION
  1909.      gets  reads  a  text string into s from the  standard  input 
  1910.      stream stdin.   The string input is terminated by a  newline 
  1911.      character, which is replaced in s by a NULL character.  gets 
  1912.      returns its argument.
  1913.  
  1914.      getns  prompts  stdout with the string p,  then reads n  - 1 
  1915.      characters,  or up to a newline character,  whichever  comes 
  1916.      first,  from  stdin.   The  last  caracter read  into  s  is 
  1917.      followed  by  NULL.   getns returns s.   Characters  entered 
  1918.      after  the  (n  - 1)th,   up  to  and  including  a  newline 
  1919.      character, are discarded.
  1920.  
  1921.      fgets  reads  n-1  text  characters,  or  up  to  a  newline 
  1922.      character,  whichever comes first,  from the stream into the 
  1923.      string  s.   The last character read into s is followed by a 
  1924.      NULL character.  fgets returns s.
  1925.  
  1926. SEE ALSO
  1927.      puts, getc, scanf, fread
  1928.  
  1929. DIAGNOSTICS
  1930.      gets and fgets return the constant pointer NULL upon end  of 
  1931.      file, empty s or error.
  1932.  
  1933. BUGS
  1934.      gets deletes a newline,  fgets keeps it,  all in the name of 
  1935.      backward compatibility.
  1936. .pa
  1937. .hehypot                                                       hypot
  1938.  
  1939.                    Euclidian Distance Function
  1940.  
  1941. NAME
  1942.      hypot 
  1943.  
  1944. SYNOPSIS
  1945.      double hypot(x, y)
  1946.      double x, y;
  1947.  
  1948. DESCRIPTION
  1949.      hypot returns
  1950.  
  1951.            sqrt(x*x + y*y),
  1952.  
  1953.      taking precautions against unwarranted overflows.
  1954.  
  1955. SEE ALSO
  1956.      sqrt
  1957.  
  1958. DIAGNOSTICS
  1959.      The INFINITY value is returned on overflow, and errno is set 
  1960.      to ERANGE.
  1961. .pa
  1962. .heindex                                                       index
  1963.  
  1964.                    String Operation Functions
  1965.  
  1966. NAME
  1967.      index,  rindex,  stradd,  strcat,  strncat, strcmp, strncmp, 
  1968.      strcpy, strncpy, streql, strindex, strlen, strsave
  1969.  
  1970. SYNOPSIS
  1971.      STRING index(s, c)
  1972.      STRING s;
  1973.      char c;
  1974.  
  1975.      STRING rindex(s, c)
  1976.      STRING s;
  1977.      char c;
  1978.  
  1979.      STRING stradd(n, s, arg[, ...])
  1980.      STRING s, arg, ...;
  1981.  
  1982.      STRING strcat(s1, s2)
  1983.      STRING s1, s2;
  1984.  
  1985.      STRING strncat(s1, s2, n)
  1986.      STRING s1, s2;
  1987.      int n;
  1988.  
  1989.      int strcmp(s1, s2)
  1990.      STRING s1, s2;
  1991.  
  1992.      int strncmp(s1, s2, n)
  1993.      STRING s1, s2;
  1994.      int n;
  1995.  
  1996.      STRING strcpy(s1, s2)
  1997.      STRING s1, s2;
  1998.  
  1999.      STRING strncpy(s1, s2, n)
  2000.      STRING s1, s2;
  2001.      int n;
  2002.  
  2003.      BOOL streql(s, t)
  2004.      STRING s, t;
  2005.  
  2006.      int strindex(s, t)
  2007.      STRING s, t;
  2008.      
  2009.      int strlen(s)
  2010.      STRING s;
  2011.  
  2012.      STRING strsave(s)
  2013.      STRING s;
  2014.  
  2015. DESCRIPTION
  2016.      These functions operate on null-terminated strings.  They do 
  2017.      not check for overflow of any receiving string.
  2018.  
  2019.      index  (rindex)  returns  a  pointer  to  the  first  (last) 
  2020.      occurance of character c in string s,  or NULL if c does not 
  2021.      occur in the string.
  2022.  
  2023.      strcat  appends a copy of string s2 to the end of string s1.  
  2024.      strncat copies at most n characters.   Both return a pointer 
  2025.      to  the  null-terminated  result.    stradd  concatenates  n 
  2026.      strings, s and arg[, ...].
  2027.  
  2028.      strcmp compares its arguments and returns an integer greater 
  2029.      than,  equal  to,  or  less than zero,  according as  s1  is 
  2030.      lexicographically greater than,  equal to,  or less than s2.  
  2031.      strncmp  makes the same comparison,  but looks at at most  n 
  2032.      characters.
  2033.  
  2034.      strcpy copies string s2 to s1.  strncpy copies n  characters 
  2035.      of s2, or all of s2, whichever is less. Both return s1.
  2036.  
  2037.      streql returns TRUE if strings s and t are the same.
  2038.  
  2039.      strindex locates one string in another, returns the index of 
  2040.      t  in  s,  or EOF if it does not exist.   This is the  index 
  2041.      function  given  in  Kernighan and  Ritchie,  page  67  (see 
  2042.      Reference 2).
  2043.  
  2044.      strlen returns the number of non-NULL characters in s.
  2045.  
  2046.      strsave  gets  enough  strorage for s  and  puts  it  there, 
  2047.      returns  the  pointer  to the string,  or NULL if  there  is 
  2048.      insufficient  string  space.   This is  from  Kernighan  and 
  2049.      Ritchie (see Reference 2, pp. 103).
  2050. .pa
  2051. .heisalpha                                                   isalpha
  2052.  
  2053.                Character Classification Functions
  2054.  
  2055. NAME
  2056.      isalnum, isalpha, isascii, iscntrl, isdigit, ishex, islower, 
  2057.      isoctal, isprint, ispunct, isspace, isupper
  2058.  
  2059. SYNOPSIS
  2060.      BOOL isalpha(c)
  2061.      int c;
  2062.      . . .
  2063.  
  2064. DESCRIPTION
  2065.      These functions classify ASCII-coded integer values by table 
  2066.      lookup.   Each  is  a predicate returning nonzero for  TRUE, 
  2067.      zero for FALSE.   isascii is defined on all integer  values; 
  2068.      the  rest are defined only where isascii is TRUE and on  the 
  2069.      single non-ASCII value EOF (see stdio).   The conditions for 
  2070.      a return of TRUE are
  2071.  
  2072. .uj0
  2073.      isalnum        c is an alphanumeric character.
  2074.  
  2075.      isalpha        c is a letter.
  2076.  
  2077.      isascii        c is an ASCII character, code less than 0x80.
  2078.  
  2079.      iscntrl        c is a delete character (0x7f)  or  ordinary 
  2080.                       control character (less than 0x20).
  2081.  
  2082.      isdigit        c is a digit.
  2083.  
  2084.      ishex          c is a hex number, 0 - 9, a - f.
  2085.  
  2086.      islower        c is a lower-case letter.
  2087.  
  2088.      isoctal        c is an octal digit, 0 - 7.
  2089.  
  2090.      isprint        c  is  a  printing    character,  code  0x20 
  2091.                       (space) through 0x7e (tilde).
  2092.  
  2093.      ispunct        c is a punctuation character (neither control 
  2094.                       nor alphanumeric).
  2095.  
  2096.      isspace        c is a space,  tab, carriage return, newline, 
  2097.                       or formfeed.
  2098.  
  2099.      isupper        c is an upper-case letter.
  2100. .uj1
  2101.  
  2102. SEE ALSO
  2103.      Macros   corresponding  to  each  of  these  functions   are 
  2104.      available in ctype.h.
  2105. .pa
  2106. .heisok                                                         isok
  2107.  
  2108.                           Quesion User
  2109.  
  2110. NAME
  2111.      isok
  2112.  
  2113. SYNOPSIS
  2114.      BOOL isok(prompt)
  2115.      STRING prompt;
  2116.  
  2117. DESCRIPTION
  2118.      prompt  outputs  to  stdout and accepts a  y/n  answer.   It 
  2119.      returns TRUE for y, and FALSE for n.
  2120. .pa
  2121. .hemalloc                                                     malloc
  2122.  
  2123.                       Main Memory Allocator
  2124.  
  2125. NAME
  2126.      malloc, free, realloc, calloc 
  2127.  
  2128. SYNOPSIS
  2129.      STRING malloc(nbytes)
  2130.      unsigned nbytes;
  2131.  
  2132.      VOID free(ptr)
  2133.      STRING ptr;
  2134.  
  2135.      STRING realloc(ptr,size)
  2136.      STRING ptr;
  2137.      unsigned size;
  2138.  
  2139.      STRING calloc(nelem, elsize)
  2140.      unsigned nelem, elsize;
  2141.  
  2142. DESCRIPTION
  2143.      malloc  and  free provide a  simple  general-purpose  memory 
  2144.      allocation package.   malloc returns a pointer to a block of 
  2145.      at least nbytes bytes beginning on a word boundary.
  2146.  
  2147.      The  argument  to  free is a pointer to a  block  previously 
  2148.      allocated  by  malloc;  this  space is  made  available  for 
  2149.      further allocation, but its contents are left undisturbed.
  2150.  
  2151.      Needless  to  say,  grave disorder will result if the  space 
  2152.      assigned  by malloc is overrun or if some random  number  is 
  2153.      handed to free.
  2154.  
  2155.      malloc  allocates  the first big-enough contiguous reach  of   
  2156.      free  space found in a circular search from the  last  block 
  2157.      allocated  or freed,  coalescing adjacent free blocks as  it 
  2158.      searches.   It calls sbrk to get more memory from the system 
  2159.      when there is no suitable space already free.
  2160.  
  2161.      realloc  changes the size of the block pointed to by ptr  to 
  2162.      size  bytes  and returns a pointer to the  (possibly  moved) 
  2163.      block.   The contents will be unchanged up to the lesser  of 
  2164.      the new and old sizes.
  2165.  
  2166.      realloc also works if ptr points to a block freed since  the 
  2167.      last call of malloc,  realloc or calloc;  thus, sequences of 
  2168.      free,  malloc and realloc can exploit the search strategy of 
  2169.      malloc to do storage compaction.    
  2170.  
  2171.      calloc  allocates  space for an array of nelem  elements  of 
  2172.      size elsize.  The space is initialized to zeros.
  2173.  
  2174.      Each  of the allocation routines returns a pointer to  space 
  2175.      suitably  aligned  (after  possible  pointer  coercion)  for 
  2176.      storage of any type of object.
  2177.  
  2178.  
  2179. DIAGNOSTICS
  2180.      malloc,  realloc  and  calloc return a NULL pointer  (0)  if 
  2181.      there  is no available memory or if the operating system has 
  2182.      detected storage corruption outside the allocated areas.
  2183.  
  2184. SEE ALSO
  2185.      allot, liberate
  2186.  
  2187. BUGS
  2188.      When realloc returns zero,  the block pointed to by ptr  may 
  2189.      be destroyed.
  2190. .pa
  2191. .hemax                                                           max
  2192.  
  2193.   Maximum and Mimimum Function for Integers, Doubles and Longs
  2194.  
  2195. NAME
  2196.      max,  min,  fmax, fmin, lmax,  lmin  
  2197.  
  2198. SYNOPSIS
  2199.      int max(a, b)
  2200.      int a, b;
  2201.  
  2202.      int min(a, b)
  2203.      int a, b;
  2204.  
  2205.      double fmax(x, y);
  2206.      double x, y;
  2207.  
  2208.      double fmin(x, y);
  2209.      double x, y;
  2210.  
  2211.      long lmax(x, y)
  2212.      long x, y;
  2213.  
  2214.      long lmin(x, y)
  2215.      long x, y;
  2216.  
  2217. DESCRIPTION
  2218.      max  and min find the maximum and the minimum of integers  a 
  2219.      and  b.    fmax and fmin do the same for doubles;  lmax  and 
  2220.      lmin do the same for longs.
  2221.  
  2222.      MAX  and MIN are macros in defs.h which take the maximum and 
  2223.      minimum values of any numeric type.
  2224.  
  2225. SEE ALSO
  2226.      defs.h
  2227. .pa
  2228. .henprob                                                       nprob
  2229.  
  2230.                   Normal Probability Functions
  2231.  
  2232. NAME
  2233.      nprob, nprobc
  2234.  
  2235. SYNOPSIS
  2236.      double nprob(x)
  2237.      double x;
  2238.  
  2239.      double nprobc(x)
  2240.      double x;
  2241.  
  2242. DESCRIPTION
  2243.      nprob  is  the normal cumulative probability function  of  a 
  2244.      random  variable having unit variance and  zero  mean,  i.e. 
  2245.      Pr{z <= x}.
  2246.  
  2247.      nprobc  is  the complementary cumulative normal  probability 
  2248.      function, i.e., nprobc(x) = 1 - nprob(x).
  2249.  
  2250. SEE ALSO
  2251.      erf, erfc
  2252. .pa
  2253. .heprintf                                                     printf
  2254.  
  2255.                    Formatted Output Conversion
  2256.  
  2257. NAME
  2258.      printf, fprintf, eprintf, sprintf, format
  2259.  
  2260. SYNOPSIS
  2261.      #include <stdio.h>
  2262.  
  2263.      VOID printf(fmt [, arg ] ... )
  2264.      STRING fmt;
  2265.      unsigned arg;
  2266.  
  2267.      VOID fprintf(stream, fmt [, arg ] ... )
  2268.      FILE *stream;
  2269.      STRING fmt;
  2270.      unsigned arg;
  2271.  
  2272.      VOID eprintf(fmt [, arg ] ... )
  2273.      STRING fmt;
  2274.      unsigned arg;
  2275.  
  2276.      VOID sprintf(s, fmt [, arg ] ... )
  2277.      STRING s, fmt;
  2278.      unsigned arg;
  2279.  
  2280.      VOID format(putsub, fmt, args)
  2281.      int (*putsub)();
  2282.      STRING fmt;
  2283.      unsigned args;
  2284.  
  2285. DESCRIPTION
  2286.      printf  places output on the standard output stream  stdout.  
  2287.      fprintf   places   output  on  the  named   output   stream. 
  2288.      eprintf(fmt [,  arg ] ... ) places output on stderr. sprintf 
  2289.      places  output  in  the  string  s,  followed  by  the  NULL 
  2290.      character.   format places output using the putsub of a list 
  2291.      of items pointed to by args.
  2292.  
  2293.      Each of these functions converts,  formats,  and prints  its 
  2294.      arg arguments under control of the fmt argument.  The fmt is 
  2295.      a  character  string  which contains two types  of  objects:  
  2296.      plain  characters,  which  are simply copied to  the  output 
  2297.      stream,  and conversion specifications, each of which causes 
  2298.      conversion  and printing of the next successive arg  of  the 
  2299.      list.
  2300.  
  2301.      Each conversion specification is introduced by the character 
  2302.      %.  Following the %, there may be
  2303.  
  2304.      -     an    optional   minus  sign  which   specifies   left 
  2305.            adjustment  of  the converted value in  the  indicated 
  2306.            field;
  2307.  
  2308.      -     an optional digit string specifying a field width;  if 
  2309.            the  converted  value has fewer  characters  than  the 
  2310.            field  width  it will be blank-padded on the left  (or 
  2311.            right,  if  the  left-adjustment  indicator  has  been 
  2312.            given) to make up the field width;  if the field width 
  2313.            begins with a zero,  zero-padding will be done instead 
  2314.            of blank-padding;
  2315.  
  2316.      -     an optional period which serves to separate the  field 
  2317.            width from the next digit string;
  2318.  
  2319.      -     an  optional digit string specifying a precision which 
  2320.            specifies  the  number of digits to appear  after  the 
  2321.            decimal point, for e- and f-conversion, or the maximum 
  2322.            number of characters to be printed from a string;
  2323.  
  2324.      -     the character l specifying that a following d,  o,  x, 
  2325.            or   u  corresponds  to  a  long  integer   arg.    (A 
  2326.            capitalized  conversion  code  accomplishes  the  same 
  2327.            thing.)
  2328.  
  2329.      -     a character which indicates the type of conversion  to 
  2330.            be applied.
  2331.  
  2332.      A  field  width or precision may be '*' instead of  a  digit 
  2333.      string.   In  this  case an integer arg supplies  the  field 
  2334.      width or precision.
  2335.  
  2336.      The conversion characters and their meanings are
  2337.  
  2338.      d,o,x The  integer arg is converted to  decimal,  octal,  or 
  2339.            hexadecimal notation respectively.
  2340.  
  2341.      f     The  float  or  double arg  is  converted  to  decimal 
  2342.            notation in the style '[-]ddd.ddd' where the number of 
  2343.            d's  after the decimal point is equal to the precision 
  2344.            specification  for the argument.   If the precison  is 
  2345.            missing,  6  digits  are given;  if the  precision  is 
  2346.            explicitly  zero,  no digits and no decimal point  are 
  2347.            printed.
  2348.  
  2349.      e     The   float  or double arg is converted in  the  style  
  2350.            '[-]d.ddde+dd'  where  there is one digit  before  the 
  2351.            decimal  point  and the number after is equal  to  the 
  2352.            precision  specification  for the argument;  when  the 
  2353.            precision is missing, 6 digits are produced.
  2354.  
  2355.      g     The  float  or double arg is printed in  style  d,  in 
  2356.            style f, or in style e, whichever gives full precision 
  2357.            in minimum space.
  2358.  
  2359.      c     The  character arg is printed.   NULL  characters  are 
  2360.            ignored.
  2361.  
  2362.      s     arg  is  taken to be a string (character pointer)  and 
  2363.            characters  from the string are printed until  a  NULL 
  2364.            character  or until the number of characters indicated 
  2365.            by the precision specification is reached;  however if 
  2366.            the  precision is zero or missing all characters up to 
  2367.            a NULL are printed.
  2368.  
  2369.      u     The  unsigned integer arg is converted to decimal  and 
  2370.            printed  (the  result  will be in the  range  zero  to 
  2371.            65535).
  2372.  
  2373.      %     Print a '%'; no argument is converted.
  2374.  
  2375.      In  no case does a non-existent or small field  width  cause 
  2376.      truncation  of  a  field;  padding takes place only  if  the 
  2377.      specified field width exceeds the actual width.   Characters 
  2378.      generated by printf are printed by putchar.
  2379.  
  2380.      Examples:
  2381.      To print a date and time in the form 
  2382.  
  2383.            Sunday, July 3, 10:02
  2384.  
  2385.      where  weekday  and month are pointers  to  null-terminated 
  2386.      strings:
  2387.  
  2388.            printf("%s,  %s %d,  %02d:%02d",  weekday, month, day, 
  2389.            hour, min);
  2390.  
  2391.      To print pi to 5 decimals:
  2392.  
  2393.            printf("pi = %.5f", 4*atan(1.0));
  2394.  
  2395. SEE ALSO
  2396.      putc, scanf
  2397.  
  2398. BUGS 
  2399.      Very wide fields (>MAXLINE characters) fail. 
  2400. .pa
  2401. .heputc                                                         putc
  2402.  
  2403.                 Put Character or Word on a Stream
  2404.  
  2405. NAME                                                        
  2406.      putc, putca, putchar, eputc
  2407.  
  2408. SYNOPSIS
  2409.      #include <stdio.h>
  2410.  
  2411.      int putc(c, stream)
  2412.      int c;
  2413.      FILE *stream;
  2414.  
  2415.      int putca(c, stream)
  2416.      int c;
  2417.      FILE *stream;
  2418.  
  2419.      int putchar(c)
  2420.      int c;
  2421.  
  2422.      int eputc(c)
  2423.      char c;
  2424.  
  2425. DESCRIPTION
  2426.      putc appends the character c to the named output stream.  It 
  2427.      returns  the character written.   putca is the same as  putc 
  2428.      except  that  '\n' is accompanied by '\r' when  CROUTADD  in 
  2429.      stdio.h is TRUE.
  2430.  
  2431.      putchar(c)  is  defined  as  the  macro  putca(c,   stdout), 
  2432.      returning c,  in stdio.h.
  2433.  
  2434.      eputc outputs c to the standard error device, stderr.  eputc 
  2435.      is defined as the macro putca(c, stderr).
  2436.  
  2437.      The standard stream stdout is normally buffered if and  only 
  2438.      if  the output does not refer to a terminal.   The  standard 
  2439.      stream  stderr is by default unbuffered unconditionally (see 
  2440.      fopen).  When  an  output stream is  unbuffered  information 
  2441.      appears  on  the  destination file or terminal  as  soon  as 
  2442.      written;  when it is buffered,  many characters are saved up 
  2443.      and written as a block.   fflush (see fclose) may be used to 
  2444.      force the block out early.
  2445.  
  2446.      putc updates the outrow[] and outcol[] of its stream->_unit.
  2447.  
  2448. SEE ALSO
  2449.      fopen, fclose, getc, puts, printf, fread, stdio.h
  2450.  
  2451. DIAGNOSTICS
  2452.      These functions return the constant EOF upon  error.   
  2453. .pa
  2454. .heputs                                                         puts
  2455.  
  2456.                     Put a String on a Stream
  2457.  
  2458. NAME
  2459.      puts, fputs, eputs
  2460.  
  2461. SYNOPSIS
  2462.      #include <stdio.h>
  2463.  
  2464.      int puts(s)
  2465.      STRING s;
  2466.  
  2467.      int fputs(s, stream)
  2468.      STRING s;
  2469.      FILE *stream;
  2470.  
  2471.      int eputs(s)
  2472.      STRING s;
  2473.  
  2474. DESCRIPION
  2475.      puts copies the text string s,  followed by newline,  to the 
  2476.      stdio device, and returns a newline character if successful, 
  2477.      EOF if not.
  2478.      
  2479.      fputs  copies the text string s to the named output  stream.  
  2480.      It returns NULL if successful, EOF if not.
  2481.  
  2482.      eputs  puts the string out to the standard error device.  It 
  2483.      returns newline if successful, EOL if not. 
  2484.  
  2485.      None of the routines copies the terminating NULL character.
  2486.  
  2487. SEE ALSO
  2488.      fopen, gets, putc, printf, ferror, fwrite
  2489.  
  2490. BUGS
  2491.      puts appends a newline,  fputs does not,  all in the name of 
  2492.      backward compatibility.
  2493. .pa
  2494. .herandom                                                     random
  2495.  
  2496.                 Random Number Generator Functions
  2497.  
  2498. NAME
  2499.      randize, random, randnorm, randexp, urandom
  2500.  
  2501. SYNOPSIS
  2502.      VOID randize(seed)
  2503.      int seed;
  2504.  
  2505.      double random()
  2506.  
  2507.      double randnorm()
  2508.  
  2509.      double randexp()
  2510.  
  2511.      unsigned urandom()
  2512.  
  2513. DESCRIPTION
  2514.      randize initializes the random number generator according to 
  2515.      seed.   If seed is zero,  an internal value is used to start 
  2516.      the generator;  if a positive value is used,  that value  is 
  2517.      converted  to  a pseudorandom starting value;  and if -1  is 
  2518.      used, an unknown value is used as the starter.
  2519.  
  2520.      random returns a uniform random value in [0, 1].
  2521.  
  2522.      randnorm  returns  a normally distributed random value  with 
  2523.      zero mean and unit standard deviation.
  2524.  
  2525.      randexp   uses   the   function  random()   to   return   an 
  2526.      exponentially distributed random value characterized by unit 
  2527.      mean, i.e. -log(random()).
  2528.  
  2529.      urandom  returns a uniform random unsigned integer value  in 
  2530.      [0, 65535].
  2531.  
  2532.      Numbers  generated  have no  serial  correlation.   Adjacent 
  2533.      samples   of  random  and  urandom  numbers  are   uniformly 
  2534.      distributed  over  the 32-cube,  and runs-up  and  runs-down 
  2535.      tests  up to length 13 would require more than 1011  samples 
  2536.      to  show  deviation  from theoretical.   The period  of  the 
  2537.      generator  is  about  1.3  * 10154.   The  numbers  form  an 
  2538.      asymptotically  random Tausworthe linear recurrance  (modulo 
  2539.      2)  sequence,  described in Ref.  12,  using  the  primitive 
  2540.      trinomial x521 + x32 + 1.
  2541. .pa
  2542. .heratfun                                                     ratfun
  2543.  
  2544.                   Rational Function Evaluation
  2545.  
  2546. NAME
  2547.      ratfun 
  2548.  
  2549. SYNOPSIS
  2550.      double ratfun(x, P, Q, n, m)
  2551.      double x, P[], Q[];
  2552.      int n, m;
  2553.  
  2554. DESCRIPTION
  2555.      ratfun returns the value of the rational function  P(x)/Q(x) 
  2556.      where n = deg(P), m = deg(Q).
  2557.  
  2558. DIAGNOSTICS
  2559.      If  the denominator is zero,  errno is set to  ERANGE;  then 
  2560.      positive  INFINITY  is  returned if the  numerator  is  non-
  2561.      negative;  otherwise,  negative  INFINITY is  returned.   On 
  2562.      underflow, errno is set to ERANGE, and zero is returned.  On 
  2563.      overflow,  errno is set to ERANGE and INFINITY of the proper 
  2564.      sign is returned.
  2565. .pa
  2566. .herkstep                                                     rkstep
  2567.  
  2568.                     Fourth Order Runga-Kutta
  2569.  
  2570. NAME
  2571.      rkstep, rknstep
  2572.  
  2573. SYNOPSIS
  2574.      VOID rkstep(f, h, t, yp)
  2575.      double (*d)(), h, t, *yp;
  2576.  
  2577.      VOID rknstep(N, f, h, t, y1, y2, dy, k, ys)
  2578.      double (*f)(), h, t, y1[], y2[], dy[], k[], ys[];
  2579.  
  2580. DESCRIPTION
  2581.      rkstep performs an integration step for a first-order  diff
  2582.      erential   equation  using  the  fourth  order   Runga-Kutta 
  2583.      formulas.   The   form  of  the  equation  is  y' = f(t, y), 
  2584.      where  y  = *yp and differentication is with respect to  the 
  2585.      first variable of f.   (See Reference 3,  pg.  896,  formula 
  2586.      25.5.10)
  2587.  
  2588.      rknstep  performs  an  integration step for  an  N-tuple  of 
  2589.      first-order ordinary differential equations using the fourth 
  2590.      order  Runga-Kutta  formulas  referenced above.   N  is  the 
  2591.      dimension  of the tuple,  y1 is the current vector state  at 
  2592.      (time) t, y2 is the calculated N-tuple state value at (time) 
  2593.      t + h returned by rknstep,  dy is a scratch array needed  to 
  2594.      hold intermediate calculations accumulating the dy value,  k 
  2595.      holds  coefficients  k1,  k2,  k3, and k4,  and ys is for  y 
  2596.      approximants  for each equation.   All of the scratch  array 
  2597.      must have dimension not less than N.
  2598.  
  2599.      The function f has 3 arguments;  f(i,  t, y), where i is the 
  2600.      vector component index,  t is the differentication variable, 
  2601.      and  y  is  the  current  state  value  vector.    That  is, 
  2602.      yi = f(i, t, y) for i = 1, 2,...,N.  In both functions, h is 
  2603.      the step size.
  2604. .pa
  2605. .hescanf                                                       scanf
  2606.  
  2607.                    Formatted Input Conversion
  2608.  
  2609. NAME
  2610.      scanf, fscanf, sscanf, unformat
  2611.  
  2612. SYNOPSIS
  2613.      #include <stdio.h>
  2614.  
  2615.      int scanf(format [ , pointer ] ... )
  2616.      STRING format;
  2617.      unsigned *pointer;
  2618.  
  2619.      int fscanf(stream, format [ , pointer ] ... )
  2620.      FILE *stream;
  2621.      STRING format;
  2622.      unsigned *pointer;
  2623.  
  2624.      int sscanf(s, format [ , pointer ] ... )
  2625.      STRING s, format;
  2626.      int *pointer;
  2627.  
  2628.      int unformat(get, format [ , pointer ] ... )
  2629.      int (*get)();
  2630.      STRING format;
  2631.      int *pointer;
  2632.  
  2633. DESCRIPTION
  2634.      scanf  reads from the standard input stream  stdin.   fscanf 
  2635.      reads  from the named input stream.   sscanf reads from  the 
  2636.      character  string  s.   unformat utilizes the  get  function 
  2637.      argument   to  fetch  characters.    Each   function   reads 
  2638.      characters,  interprets them according to format, and stores 
  2639.      the  results  in  its remaining  arguments.   Each  function 
  2640.      expects  as  arguments a control  string  format,  described 
  2641.      below,  and a set of pointer arguments indicating where  the 
  2642.      converted input should be stored.
  2643.  
  2644.      The    control    string   usually    contains    conversion 
  2645.      specifications,  which  are used to direct interpretation of 
  2646.      input sequences.  The control string may contain:
  2647.  
  2648.      1.    Blanks,  tabs or newlines,  which match optional white 
  2649.            space in the input.
  2650.  
  2651.      2.    An  ordinary  character (not %) which must  match  the 
  2652.            next character of the input stream.
  2653.  
  2654.      3.    Conversion specifications, consisting of the character 
  2655.            %,  an optional assignment suppressing character *, an 
  2656.            optional   numerical  maximum  field  width,   and   a 
  2657.            conversion character.
  2658.    
  2659.      A  conversion  specification directs the conversion  of  the 
  2660.      next  input  field;  the result is placed  in  the  variable 
  2661.      pointed to by the corresponding argument,  unless assignment 
  2662.      suppression  was indicated by *.   An input field is defined 
  2663.      as a string of non-space characters;  it extends to the next 
  2664.      inappropriate  character  or  until  the  field  width,   if 
  2665.      specified, is exhausted.
  2666.  
  2667.      The conversion character indicates the interpretation of the 
  2668.      input field; the corresponding pointer argument must usually 
  2669.      be   of  a  restricted  type.    The  following   conversion 
  2670.      characters are legal:
  2671.  
  2672.      %     a  single '%' is expected in the input at this  point; 
  2673.            no assignment is done.
  2674.  
  2675.      d     a  decimal  integer  is  expected;  the  corresponding 
  2676.            argument should be an integer pointer.
  2677.  
  2678.      o     an  octal  integer  is  expected;   the  corresponding 
  2679.            argument should be an integer pointer.
  2680.  
  2681.      x     a hexadecimal integer is expected;  the  corresponding 
  2682.            argument should be an integer pointer.
  2683.  
  2684.      s     a  character  string is  expected;  the  corresponding 
  2685.            argument should be a character pointer pointing to  an 
  2686.            array  of characters large enough to accept the string 
  2687.            and  a terminating NULL,  which will  be  added.   The 
  2688.            input  field  is terminated by a space character or  a 
  2689.            newline.
  2690.  
  2691.      c     a  character is expected;  the corresponding  argument 
  2692.            should  be a character pointer.   The normal skip over 
  2693.            space characters is suppressed in this case;  to  read 
  2694.            the next non-space character,  try '%1s'.   If a field   
  2695.            width  is  given,  the corresponding  argument  should 
  2696.            refer to a character array,  and the indicated  number 
  2697.            of characters is read.
  2698.  
  2699.      e     a floating point number is expected; the next field is 
  2700.      f     converted   accordingly   and   stored   through   the 
  2701.            corresponding argument, which should be a pointer to a 
  2702.            float.  The input format for floating point numbers is 
  2703.            an   optionally  signed  string  of  digits   possibly 
  2704.            containing  a decimal point,  followed by an  optional 
  2705.            exponent  field consisting of an E or e followed by an 
  2706.            optionally signed integer.
  2707.  
  2708.      [     indicates  a  string  not to  be  delimited  by  space 
  2709.            characters.   The left bracket is followed by a set of 
  2710.            characters and a right bracket; the characters between 
  2711.            the brackets define a set of characters making up  the  
  2712.            string.  If the first character is not circumflex (^), 
  2713.            or tilde (~),  the input field is all characters until 
  2714.            the  first  character  not  in  the  set  between  the 
  2715.            brackets;  if  the  first  character  after  the  left 
  2716.            bracket is ^ (or ~), the input field is all characters 
  2717.            until  the  first character which is in the  remaining 
  2718.            set   of   characers  between   the   brackets.    The 
  2719.            corresponding  argument  must  point  to  a  character 
  2720.            array.
  2721.  
  2722.      The conversion characters d,  o and x may be capitalized  or 
  2723.      preceeded  by  l to indicate that a pointer to  long  rather 
  2724.      than  to  int  is in  the  argument  list.   Similarly,  the 
  2725.      conversion  characters e or f may be capitalized or preceded 
  2726.      by  L  to indicate a pointer to double rather than to float.  
  2727.      The conversion characters d,  o and x may be preceeded by  h 
  2728.      to  indicate  a pointer to short rather than  to  int.   The 
  2729.      conversion  hd  may  be shortened to only h  to  conform  to 
  2730.      Kernighan and Ritchie (Reference 2).
  2731.  
  2732.      The  scanf  functions  return  the  number  of  successfully 
  2733.      matched  and  assigned  input items.   This can be  used  to 
  2734.      decide how many input items were found.  The constant EOF is 
  2735.      returned upon end of input; note that this is different from 
  2736.      zero, which means that no conversion was done; if conversion 
  2737.      was  intended,   it  was  frustrated  by  an   inappropriate 
  2738.      character in the input.
  2739.  
  2740.      For example, the call
  2741.  
  2742.            int i; 
  2743.            float x; 
  2744.            char name[50];
  2745.            scanf( "%d%f%s", &i, &x, name);
  2746.  
  2747.      with the input line
  2748.  
  2749.            25  54.32E-1  synott
  2750.  
  2751.      will assign to i the value 25,  x the value 5.432,  and name 
  2752.      will contain 'synott'.  Or,
  2753.  
  2754.            int i; 
  2755.            float x; 
  2756.            char name[50];
  2757.            scanf("%2d%f%*d%[1234567890]", &i, &x, name);
  2758.  
  2759.      with input
  2760.  
  2761.            56789  0123  56a72
  2762.  
  2763.      will assign 56 to i,  789.0 to x, skip '0123', and place the 
  2764.      string  '56' in name.   The next call to getchar will return 
  2765.      'a'.
  2766.  
  2767.      The get argument of the unformat function itself uses a mode 
  2768.      argument: get(TRUE) is assumed to perform a character input, 
  2769.      and get(FALSE) does an unget on the last character fetched.
  2770.  
  2771.  
  2772. SEE ALSO
  2773.      atof, getc, printf
  2774.  
  2775. DIAGNOSTICS
  2776.      The scanf functions return EOF on end of input,  and a short 
  2777.      count for missing or illegal data items.
  2778.  
  2779. BUGS
  2780.      The   success   of  incompatible  types  is   not   directly 
  2781.      determinable.
  2782. .pa
  2783. .hescreen i/o                                             screen i/o
  2784.  
  2785.                        Screen Input/Output
  2786.  
  2787. NAME
  2788.      altscrn,  clrscrn,  cursor,  eraeol,  eraeop, home, iniscrn, 
  2789.      normscrn, putscrn, uniscrn
  2790.  
  2791. SYNOPSIS
  2792.      #include <scrnio.h>
  2793.  
  2794.      BOOL altscrn()
  2795.  
  2796.      VOID clrscrn()
  2797.  
  2798.      BOOL cursor(r, c)
  2799.      int r, c;
  2800.  
  2801.      BOOL eraeol(r, c)
  2802.      int r, c;
  2803.  
  2804.      BOOL eraeop(r, c)
  2805.      int r, c;
  2806.  
  2807.      VOID home()
  2808.  
  2809.      VOID iniscrn()
  2810.  
  2811.      BOOL normscrn()
  2812.  
  2813.      METACHAR putscrn(c)
  2814.      int c;
  2815.  
  2816.      VOID uniscrn()
  2817.  
  2818. DESCRIPTION
  2819.      altscrn  begins the alternate-intensity mode.   If this is a 
  2820.      system supported function,  altscrn returns TRUE; if not, it 
  2821.      returns FALSE.
  2822.  
  2823.      clrscrn  clears and erases the terminal screen  and  returns 
  2824.      the cursor to the home position.
  2825.  
  2826.      cursor  positions  the  cursor  at  row  r,  column  c.   If 
  2827.      successful,  this  function returns TRUE.   If a  coordinate 
  2828.      addreessing error is sensed, it will return FALSE.
  2829.  
  2830.      eraeol  erases row r from column c to the end of  the  line.  
  2831.      It will return TRUE if successful, or FALSE on improper r or 
  2832.      c.  The cursor is positioned at row r, column c afterward.
  2833.  
  2834.      eraeop  erases from row r,  column c to the end of the page.  
  2835.      TRUE  is  normally returned;   improper r or  c  will  cause 
  2836.      eraeop to return FALSE.   The cursor is positioned at row r, 
  2837.      column c afterward.
  2838.  
  2839.      home  moves  the  cursor to row zero,  column  zero  of  the 
  2840.      terminal.
  2841.  
  2842.      iniscrn  sends the initialization sequence to the  terminal, 
  2843.      if it exists.
  2844.  
  2845.      normscrn begins the normal-intensity mode.   It returns TRUE 
  2846.      if this function is supported, or FALSE if not.
  2847.  
  2848.      putscrn sends the character c to the terminal in  unbuffered 
  2849.      mode.    outcol[STDOUT]  and  outrow[STDOUT]  are  correctly 
  2850.      updated, ie., putscrn will be ignored if the screen size has 
  2851.      been exceeded.
  2852.  
  2853.      uniscrn   sends   the  un-initialization  sequence  to   the 
  2854.      terminal, if it exits.
  2855.  
  2856.      Global  variables outrow[STDOUT] and outcol[STDOUT] hold the 
  2857.      current position of the cursor at all times.
  2858.  
  2859.      scrnio.h  is  the data file which declares all  global  data 
  2860.      necessary  for the use of these terminal display  functions.  
  2861.      scrnio.h should be included before stdio.h in every  program 
  2862.      using screen i/o functions.
  2863.  
  2864.      Row  0  is  the topmost row,  and column 0 is  the  leftmost 
  2865.      column.
  2866.  
  2867. BUGS
  2868.      These functions may not operate on systems in which terminal 
  2869.      output cannot be direct.
  2870. .pa
  2871. .hesetbuf                                                     setbuf
  2872.  
  2873.                           Assign Buffer
  2874.  
  2875. NAME
  2876.      setbuf
  2877.  
  2878. SYNOPSIS
  2879.      VOID setbuf(fp, buffer)
  2880.      FAST FILE *fp;
  2881.      BUFFER buffer;
  2882.  
  2883. DESCRIPTION
  2884.      setbuf is used after a stream has been opened but before  it 
  2885.      is read or written.   If fp already has a buffer assigned to 
  2886.      it,  it causes the character array buffer to be used instead 
  2887.      of  an  automatically  allocated buffer.   Any data  in  the 
  2888.      existing buffer is lost.   If buffer is the constant pointer 
  2889.      NULL, input/output will be completely unbuffered.
  2890.  
  2891.      Use  of setbuf(stdin,  NULL) at the beginning of  a  program 
  2892.      assures that terminal input will be unbuffered.
  2893.  
  2894. BUGS
  2895.      Unbuffered     terminal    input    depends    on    whether 
  2896.      read(0, buffer, 1)   returns  a  byte  immediately   or   is 
  2897.      internally buffered for line editing purposes.
  2898. .pa
  2899. .hesgn                                                           sgn
  2900.  
  2901.                           Sign Function
  2902.  
  2903. NAME
  2904.      sgn 
  2905.  
  2906. SYNOPSIS
  2907.      double sgn(x)
  2908.      double x;
  2909.  
  2910. DESCRIPTION
  2911.      sgn will return the double sgn function of x,  i.e., +1, -1, 
  2912.      or  0,  accordingly as x is  positive,  negative,  or  zero, 
  2913.      respectively.
  2914.  
  2915.      SGN  is  the macro in header file defs.h which performs  the 
  2916.      same  function,  except for side effects,  and on all signed 
  2917.      numeric types.
  2918. .pa
  2919. .hesimpson                                                   simpson
  2920.  
  2921.              Integration by Simpson's Modified Rule
  2922.  
  2923. NAME
  2924.      simpson 
  2925.  
  2926. SYNOPSIS
  2927.      double simpson(func, lowlim, uplim, n)
  2928.      double (*func)(), lowlim, uplim;
  2929.      int n;
  2930.  
  2931. DESCRIPTION
  2932.      simpson  integrates  the function func from lowlim to  uplim 
  2933.      using 2n points,  according to the Simpson integration rule.  
  2934.      The error value is given by
  2935.  
  2936.           e = -(n * h5/90) * funciv(x)
  2937.  
  2938.      where  h  =  (uplim - lowlim)/(2n) and lowlim < x  <  uplim.  
  2939.      (see Reference 3, formula 25.4.6)
  2940. .pa
  2941. .hesin                                                           sin
  2942.  
  2943.                      Trigonometric Functions
  2944.  
  2945. NAME
  2946.      sin, cos, tan, asin, acos, atan, atan2, cotan 
  2947.  
  2948. SYNOPSIS
  2949.      #include <mathcons.h>
  2950.  
  2951.      double sin(x)
  2952.      double x;
  2953.  
  2954.      double cos(x)
  2955.      double x;
  2956.  
  2957.      double tan(x)
  2958.      double x;
  2959.  
  2960.      double asin(x)
  2961.      double x;
  2962.  
  2963.      double acos(x)
  2964.      double x;
  2965.  
  2966.      double atan(x)
  2967.      double x;
  2968.  
  2969.      double atan2(x, y)
  2970.      double x, y;
  2971.  
  2972.      double cotan(x)
  2973.      double x;
  2974.  
  2975. DESCRIPTION
  2976.      All  of these functions were programmed using the algorithms 
  2977.      given  in Software Manual for the Elementary Functions  (see 
  2978.      Reference 5).
  2979.  
  2980.      sin,  cos  and tan return trigonometric functions of  radian 
  2981.      arguments.   The magnitude of the argument should be checked 
  2982.      by the caller to make sure the result is  meaningful.   (see 
  2983.      Reference 5, pp. 125-149 and 150-173)
  2984.  
  2985.      asin returns the arc sin in the range -pi/2 to +pi/2.
  2986.  
  2987.      acos returns the arc cosine in the range zero to pi.
  2988.      
  2989.      atan  returns  the  arc tangent of x in the range  -pi/2  to 
  2990.      +pi/2.  (see Reference 5, pp. 194-216)
  2991.  
  2992.      atan2 returns the arc tangent of x/y in the range -pi to +pi.
  2993.  
  2994.      cotan returns the cotangent of x.
  2995.  
  2996. DIAGNOSTICS
  2997.      Arguments  of  magnitude greater than unity cause  asin  and 
  2998.      acos to return value 0;  errno is set to EDOM.  The value of 
  2999.      tan at its singular points is INFINITY,  and errno is set to 
  3000.      ERANGE.
  3001.  
  3002. BUGS
  3003.      The  value  of tan for arguments greater  than  MAXANGLE  is 
  3004.      garbage.
  3005. .pa
  3006. .hesinh                                                         sinh
  3007.  
  3008.                       Hyperbolic Functions
  3009.  
  3010. NAME
  3011.      sinh, cosh, tanh 
  3012.  
  3013. SYNOPSIS
  3014.      #include <mathtyp.h>
  3015.  
  3016.      double sinh(x)
  3017.      double x;
  3018.  
  3019.      double cosh(x)
  3020.      double x;
  3021.  
  3022.      double tanh(x)
  3023.      double x;
  3024.  
  3025. DESCRIPTION
  3026.      These  functions compute the designated hyperbolic functions 
  3027.      for real arguments.
  3028.  
  3029.      All  were programmed using the algorithms given in  Software 
  3030.      Manual  for the Elementary Functions (see Reference  5,  pp. 
  3031.      217-238 and 239-255).
  3032.  
  3033. DIAGNOSTICS
  3034.      sinh  and cosh return INFINITY of appropriate sign when  the 
  3035.      correct value would overflow.
  3036. .pa
  3037. .hesortH                                                       sortH
  3038.  
  3039.                          Sort Functions
  3040.  
  3041. NAME
  3042.      sortH, sortS, sortQ, sortB, qsort
  3043.  
  3044. SYNOPSIS
  3045.      VOID sortH(n, comp, exch)
  3046.      int n, (*comp)();
  3047.      VOID (*exch)();
  3048.      
  3049.      VOID sortS(n, comp, exch)
  3050.      int n, (*comp)();
  3051.      VOID (*exch)();
  3052.  
  3053.      VOID sortQ(n, comp, exch)
  3054.      int n, (*comp)();
  3055.      VOID (*exch)();
  3056.  
  3057.      VOID sortB(n, comp, exch)
  3058.      int n, (*comp)();
  3059.      VOID (*exch)();
  3060.  
  3061.      VOID qsort(base, n, width, compar)
  3062.      STRING base;
  3063.      int n, width, (*compar)();
  3064.  
  3065. DESCRIPTION
  3066.      Each  of  these functions will sort an array of size n  with 
  3067.      respect  to  a  comparison function  comp(i,  j),  which  is 
  3068.      positive,  if and only if elements i and j of the array  are 
  3069.      out  of order.    The exch(i,  j) function exchanges the ith 
  3070.      and jth elements of the array.   The name and type of  array 
  3071.      are unknown to the sort routines,  but must,  of course,  be 
  3072.      known to exch and comp.
  3073.  
  3074.      sortH   uses  the heapsort algorithm,  with time  complexity 
  3075.      O(n * log(n)).  (See Reference 10, pp. 87-92.)
  3076.  
  3077.      sortS uses the Shell sort algorithm, with time complexity of 
  3078.      about O(n1.5). (See References 2 and 9.)
  3079.  
  3080.      sortQ   uses  the  quicksort algorithm,  of time  complexity 
  3081.      O(n * log(n)) to O(n2).  (See Reference 11.)
  3082.  
  3083.      sortB performs a bubble-sort in which large values bubble up 
  3084.      and low values shuttle down in the array, O(n) to O(n2).
  3085.  
  3086.      qsort  is another implementation of the quicksort algorithm.  
  3087.      The base is a pointer to the beginning of the data; n is the 
  3088.      number  of  elements;  third is the width of an  element  in 
  3089.      bytes;  last  is  the name of the comparison routine  to  be 
  3090.      called  with two arguments,  pointers to the elements  being 
  3091.      compared.   The  comparison must return an  integer  greater 
  3092.      than zero if and only if the elements being compared are out 
  3093.      of sort.
  3094. .pa
  3095. .hetolower                                                   tolower
  3096.  
  3097.                Conversion to Lower and Upper Case
  3098.  
  3099. NAME
  3100.      tolower, toupper 
  3101.  
  3102. SYNOPSIS
  3103.      char tolower(c)
  3104.      int c;
  3105.  
  3106.      char toupper(c)
  3107.      int c;
  3108.  
  3109. DESCRIPTION
  3110.      tolower returns the lower case of c,  if c is an  upper-case 
  3111.      letter.
  3112.  
  3113.      toupper  returns the upper case of c,  if c is a  lower-case 
  3114.      letter.
  3115.  
  3116.      TOLOWER  and  TOUPPER are the macros found  in  header  file 
  3117.      ctype.h  which are identical to the functions above,  except 
  3118.      for side-effects.
  3119. .pa
  3120. .heungetc                                                     ungetc
  3121.  
  3122.               Push Character Back into Input Stream
  3123.  
  3124. NAME
  3125.      ungetc 
  3126.  
  3127. SYNOPSIS
  3128.      #include <stdio.h>
  3129.  
  3130.      int ungetc(c, stream)
  3131.      int c;
  3132.      FILE *stream;
  3133.  
  3134. DESCRIPTION
  3135.      ungetc pushes the character c back on an input stream.  That 
  3136.      character  will  be returned by the next getc call  on  that 
  3137.      stream.  ungetc returns c.
  3138.  
  3139.      One  character of pushback is guaranteed provided  something 
  3140.      has  been  read from the stream and the stream  is  actually 
  3141.      buffered.  
  3142.  
  3143.      fseek erases all memory of pushed back characters.
  3144.  
  3145. SEE ALSO
  3146.      getc, fseek
  3147.  
  3148. DIAGNOSTICS
  3149.      ungetc returns EOF if c is EOF.
  3150. .he
  3151. .pa o
  3152. .PN 1
  3153. .FO                                5-#
  3154.              5. C U S T O M I Z A T I O N   N O T E S 
  3155.  
  3156.      There  are  approximately 162 functions and  167  parameters 
  3157. (constants, macros, and global variables) names in the portable C 
  3158. subroutine library.  Of these, 12 are system functions, for which 
  3159. source  code is not included,  and another 145 functions and  152 
  3160. parameters that are machine-independent.  One of the system-level 
  3161. functions and the remaining 5 functions and 56 parameters must be 
  3162. customized  to the ideosyncracies of the host  environment.   The 
  3163. system interface functions are listed in Table 5-1,  the elements 
  3164. that  must  be given attention are listed in Table 5-2,  and  the 
  3165. machine-independent  elements  are  given  in  Table  5-3.    All 
  3166. elements are listed in Table 5-4.
  3167.  
  3168.      The  procedures  for effecting the needed changes  from  the 
  3169. distribution  source  is  contained  in  the  remainder  of  this 
  3170. section.
  3171. .po11
  3172.  
  3173.  
  3174.  
  3175.                    Table 5-1: PORTABLE C LIBRARY SYSTEM INTERFACE
  3176.  
  3177. Element      Type       File                    Description               
  3178.  
  3179. close        function   csys.lib     Close file OS interface.                 
  3180. creat        function   csys.lib     Create file function, OS interface.      
  3181. exit         function   csys.lib     Close all files and terminate program.   
  3182. lseek        function   csys.lib     Move file position using arg as offset.  
  3183. open         function   csys.lib     Open file for operation, OS interface.   
  3184. read         function   csys.lib     Read from stream into buffer: OS interfc 
  3185. rename       function   csys.lib     Rename a file: OS interface.             
  3186. sbrk         function   csys.lib     Set pointer to available memory: OS i/f. 
  3187. unlink       function   csys.lib     Unlink a file name from a file (delete). 
  3188. write        function   csys.lib     File write OS interface.                 
  3189. _exit        function   csys.lib     Immediate termination of program.        
  3190.  
  3191. .pa
  3192.         Table 5-2: PORTABLE C LIBRARY COMPILER- & SYSTEM-DEPENDENT ELEMENTS
  3193.  
  3194. Element      Type       File                    Description               
  3195.  
  3196. ALIGN        typedef    stdtyp.h     K & R storage allocation header aligner. 
  3197. ALTSCRN      TEXT       scrnio.h     Terminal into alternate intensity string 
  3198. astof        function   atof.c       ASCII number to (double) float. Pointer. 
  3199. BIG10X       constant   mathcons.h   Largest 10^(2^(BIG10X -1)) < INFINITY    
  3200. BIGX         constant   mathcons.h   16 * log2(INFINITY) - 1                  
  3201. BUFSIZ       constant   stdio.h      I/O stream buffer size.                  
  3202. CB4L         TBOOL      scrnio.h     Column-before-row boolean.               
  3203. chrstc       function   chrstc.c     Return int characteristic of double.     
  3204. CLEARSCREEN  TEXT       scrnio.h     Terminal clear-screen string.            
  3205. COFFSET      tiny       scrnio.c     Cursor lead-in column offset value.      
  3206. CRINSUP      constant   stdio.h      Set TRUE to suppress CR text input.      
  3207. CROUTADD     constant   stdio.h      Set true to echo '\n' with CR.           
  3208. DPRECISION   constant   mathcons.h   (int) PRECISION                          
  3209. EDOM         constant   errno.h      Function argument not in defined domain. 
  3210. EOF          constant   defs.h       Standard End-of-File value.              
  3211. ERAEOLN      TEXT       scrnio.c     Terminal Erase-to-End-of-Line string.    
  3212. ERAEOPG      TEXT       scrnio.h     Terminal erase-to-end-of-page string.    
  3213. fint         function   fint.c       Float (double) INTeger-part function.    
  3214. ftoa         function   ftoa.c       Float (double) to ASCII conversion.      
  3215. HEIGHT       tiny       scrnio.h     Terminal height, number of lines.        
  3216. HOME         string     scrnio.h     Terminal cursor-to-home (0,0) string.    
  3217. INFINITY     constant   mathcons.h   Largest double value on this machine.    
  3218. INFINLEG     constant   math.cons    INFINITY / ROOTTWO.                      
  3219. ldexp        function   frexp.c      Load exponent (multiply by power of 2).  
  3220. LEADIN       TEXT       scrnio.h     Cursor lead-in sequence.                 
  3221. LEAST        constant   mathcons.h   Least double representable in machine.   
  3222. LINDELETE    TEXT       scrnio.c     Terminal line-delete string.             
  3223. LININSERT    TEXT       scrnio.h     Terminal line-delete string.             
  3224. LOGINFINITY  constant   mathcons.h   Largest argument of log function.        
  3225. LOGLEAST     constant   mathcons.h   Log of smallest machine number           
  3226. mathcons.h   header     mathcons.h   Constant file for math functions.        
  3227. MAXCHANNELS  constant   global.h     Maximum number of i/o channels at once.  
  3228. MAXEXP       constant   mathcons.h   Largest numeric characteristic.          
  3229. MAXEXPG      constant   mathcons.h   MAXEXP - 3 guard bits.                   
  3230. MAXLINE      constant   stdio.h      Maximum no. of chars. on input line.     
  3231. MAXSTREAM    constant   stdio.h      Maximum number of buffered i/o streams.  
  3232. MINEXP       constant   mathcons.h   Characteristic of least machine double.  
  3233. MINEXPG      constant   mathcons.h   MINEXP + 3 guard bits.                   
  3234. NALLOC       constant   stdtyp.h     No. of HEADER units for malloc().         
  3235. NORMSCRN     TEXT       scrnio.h     Terminal string, return normal intensity 
  3236. PMODE        constant   stdio.h      fopen() protection mode (for UNIX).      
  3237. PRECISION    constant   mathcons.h   -log10(WASHOUT).                         
  3238. RCENDER      TEXT       scrnio.h     Row-column lead-in terminator.           
  3239. RCSEPARATOR  TEXT       scrnio.h     Cursor row, column separator string.     
  3240. rename       function   csys.lib     Rename a file: OS interface.             
  3241. ROFFSET      tiny       scrnio.h     Cursor lead-in row offset value.         
  3242. RTHLFINF     constant   mathcons.h   sqrt(INFINITY / 2).                      
  3243. SCRNINI      TEXT       scrnio.h     Initialize-terminal string.              
  3244. SCRNUNI      TEXT       scrnio.h     Terminal un-initialize string.           
  3245. SCRNWRAP     TBOOL      scrnio.h     Signal for auto terminal wrap-around.    
  3246. SMALLX       constant   mathcons.h   16 * log2(LEAST) + 1.0                   
  3247.  
  3248.           PORTABLE C LIBRARY COMPILER- & SYSTEM-DEPENDENT  ELEMENTS (cont.)        
  3249.  
  3250. Element      Type       File                    Description               
  3251.  
  3252. SYMLEAST     constant   mathcons.h   Symmetric Least value (1/SYMLEAST) exist 
  3253. SYS_EOF      macro      stdio.h      System end-of-file marker, if any.       
  3254. TANHXBIG     constant   mathcons     (No. sig bits + 2) * log(2) / 2          
  3255. TBITS        typedef    stdtyp.h     Tiny (8 char min) for bit manipulation.  
  3256. TBOOL        typedef    stdtyp.h     Tiny (8 char min) used tor boolean.      
  3257. TERMINAL     TEXT       scrnio.h     Terminal identification string.          
  3258. TINY         macro      stdtyp.h     rvalue for tiny.                         
  3259. USELAST      TBOOL      scrnio.h     Signal to use final terminal column.     
  3260. UTINY        macro      stdtyp.h     rvalue for utiny.                        
  3261. WASHOUT      constant   mathcons.h   1.0 + (x < WASHOUT) = 1.0 to precision.  
  3262. WIDTH        tiny       scrnio.h     Terminal width, number of characters.    
  3263. XLT2ASCII    TBOOL      scrnio.h     Translate-to-ASCII boolean.              
  3264. .pa
  3265.  
  3266.              Table 5-3: PORTABLE C LIBRARY SYSTEM-INDEPENDENT ELEMENTS
  3267.  
  3268. Element      Type       File                    Description               
  3269.  
  3270. ABS          macro      defs.h       Absolute value of any numeric type.      
  3271. abs          function   abs.c        Absolute value function, int.            
  3272. acos         function   asin.c       arc cosine, double.                      
  3273. allot        function   malloc.c     malloc() without header overhead.         
  3274. altscrn      function   scrnio.c     Set terminal to alternate intensity.     
  3275. AND          macro      defs.h       Logical "and" operator, &&.              
  3276. asin         function   asin.c       Arc sine function, double.               
  3277. astoi        function   atoi.c       ASCII int to int. Also returns pointer.  
  3278. astol        function   atol.c       ASCII to long. Also returns pointer.     
  3279. atan         function   atan.c       Arc tangent, double.                     
  3280. atan2        function   atan.c       Two-argument arc tangent, double.        
  3281. atof         function   atof.c       ASCII to (double) float.                 
  3282. atoi         function   atoi.c       ASCII to int.                            
  3283. atol         function   atol.c       ASCII to long.                           
  3284. bitcount     function   bitcount.c   K & R function counts bits in argument.  
  3285. BITS         typedef    stdtyp.h     Short used only for bit manipulation.    
  3286. BOOL         typedef    stdtyp.h     Int used only for boolean.               
  3287. BUFFER       typedef    stdtyp.h     Used only for pointers to char buffers.  
  3288. calloc       function   malloc.c     C allocation for arrays.                 
  3289. cbrt         function   cbrt.c       Cube root function, double.              
  3290. CBRTFOUR     constant   mathcons.h   Cube root of 4.                          
  3291. CBRTTWO      constant   mathcons.h   Cube root of 2.                          
  3292. ceil         function   floor.c      Ceiling function of double.              
  3293. clearerr     macro      stdio.h      Reset error indicator on file stream.    
  3294. clrscrn      function   scrnio.c     Clear terminal screen.                   
  3295. cos          function   sin.c        Cosine function, double.                 
  3296. cosh         function   cosh.c       Hyperbolic cosine, double.               
  3297. cotan        function   tan.c        Cotangent function, double.              
  3298. CURPOS       constant   stdio.h      Current file position seek indicator.    
  3299. cursor       function   scrnio.c     Position terminal cursor at row, column. 
  3300. eprintf      function   eprintf.c    Formatted print to stderr.               
  3301. eputc        macro      stdio.c      Put character out to stderr.             
  3302. eputs        function   eputs.c      Put string out to stderr.                
  3303. eraeol       function   scrnio.c     Erase terminal screen to end of line.    
  3304. eraeop       function   scrnio.c     Erase terminal screen to end of page.    
  3305. ERANGE       constant   errno.h      Computed math value out of range.        
  3306. erf          function   erf.c        Error function, double.                  
  3307. erfc         function   erf.c        Complimentary error function, double.    
  3308. errno        short      global.h     Standard error variable.                 
  3309. exp          function   exp.c        Exponential function, double.            
  3310. fabs         function   fabs.c       Absolute value function, double.         
  3311. FADEOUT      constant   mathcons.h   Magnitude of washout term in Taylor ser. 
  3312. FAIL         constant   defs.h       Standard Failure value.                  
  3313. FALSE        constant   defs.h       Standard False value.                    
  3314. fclosall     function   putc.c       Close all buffered i/o streams.          
  3315. fclose       function   fopen.c      Close file using descriptor.             
  3316. feof         macro      stdio.h      Evaluate end-of-file status, int.        
  3317. ferror       macro      stdio.h      Boolean for file i/o error.              
  3318. fflush       function   fopen.c      Flush file buffers to the medium.        
  3319. fgets        function   fgets.c      Get string from file (buffered).         
  3320.  
  3321.                PORTABLE C LIBRARY SYSTEM-INDEPENDENT ELEMENTS (cont.)             
  3322.  
  3323. Element      Type       File                    Description               
  3324.  
  3325. FILE         typedef    stdio.h      Standard file type declaration.          
  3326. FILEND       constant   stdio.h      File end seek position designator.       
  3327. fileno       macro      stdio.h      Return file descriptor of stream.        
  3328. floor        function   floor.c      Floor function, double.                  
  3329. flush        function   putc.c       Flush output buffer when char overflow.  
  3330. fmax         function   fminmax.c    Maximum of a, b, double.                 
  3331. fmin         function   fminmax.c    Minimum of a, b, double.                 
  3332. fopen        function   fopen.c      Open file for buffered operation.        
  3333. FOREVER      macro      defs.h       Same as "for (::)".                      
  3334. format       function   format.c     Basic output format utility.             
  3335. FOURTHLOG2   constant   mathcons.h   log(2) / 4                               
  3336. fprintf      function   fprintf.c    Formatted output to file.                
  3337. fputs        function   fputs.c      Put string out to file, unformatted.     
  3338. frac         function   frac.c       Fractional-part function, double.        
  3339. fread        function   fread.c      Buffered read from file.                 
  3340. free         function   malloc.c     Free previously allocated storage.       
  3341. frexp        function   frexp.c      Fraction (mantissa) and exponent, double 
  3342. fscanf       function   fscanf.c     Formatted scan inputs from file.         
  3343. fseek        function   fseek.c      Buffered file reposition function.       
  3344. ftell        function   ftell.c      Return current file offset from origin.  
  3345. fwrite       function   fwrite.c     Buffered write to file.                  
  3346. getbuf       function   getbuf.c     Get an i/o buffer from allot().          
  3347. getc         function   getc.c       Get character from file.                 
  3348. getca        function   getc.c       Get ASCII char from buffered i/o stream. 
  3349. getchar      macro      stdio.c      Get character from stdin.                
  3350. getf         function   getf.c       Prompt and get double from stdin.        
  3351. geti         function   geti.c       Prompt and get integer from stdin.       
  3352. getl         function   getl.c       Prompt and get long from stdin.          
  3353. getns        function   getns.c      Prompt and get string from stdin.        
  3354. gets         function   gets.c       Get string from stdin.                   
  3355. GLOBAL       macro      stdtyp.h     Pseudo storage class (extern) for port.  
  3356. GZ           macro      defs.h       Greater than Zero, GZ(x) = (x>0? x : 0)  
  3357. HALFLOG2e    constant   mathcons.h   log2(e) / 4                              
  3358. HEADER       typedef    stdtyp.h     K & R storage allocation block type.     
  3359. home         function   scrnio.c     Home the terminal cursor.                
  3360. hypot        function   hypot.c      Compute hypotenuse of right triangle.    
  3361. index        function   index.c      Find position of char in string arg.     
  3362. iniscrn      function   scrnio.c     Initialize terminal screen output.       
  3363. inverf       function   inverf.c     Inverse of error function, erf, double.  
  3364. inverfc      function   inverf.c     Inverse of complementart error function. 
  3365. INVPI        constant   mathcons.h   1.0 / pi                                 
  3366. IObuffs      buffers    stdio.h      I/O buffers for buffered streams.        
  3367. IS           macro      defs.h       Logical equivalence operator, ==.        
  3368. isalnum      function   isalnum.c    True if arg is alpha or number.          
  3369. ISALNUM      macro      ctype.h      True if arg is alpha or number.          
  3370. isalpha      function   isalpha.c    True if arg is alpha.                    
  3371. ISALPHA      macro      ctype.h      True if arg is alpha.                    
  3372. isascii      function   isascii.c    True if arg is < 128.                    
  3373. ISASCII      macro      ctype.h      True if arg < 128.                       
  3374. iscntrl      function   iscntrl.c    True if arg is control or DEL character. 
  3375.  
  3376.              PORTABLE C LIBRARY SYSTEM-INDEPENDENT ELEMENTS (cont.)
  3377.  
  3378. Element      Type       File                    Description               
  3379.  
  3380. ISCNTRL      macro      ctype.h      True if arg is control or DEL character. 
  3381. isdigit      function   isdigit.c    True if arg is decimal digit.            
  3382. ISDIGIT      macro      ctype.h      True if arg is decimal digit.            
  3383. ishex        function   ishex.c      Returns TRUE if argument is hex number.  
  3384. islower      function   islower.c    True if arg is lower-case alpha.         
  3385. ISLOWER      macro      ctype.h      True if arg is lower case alpha.         
  3386. ISNT         macro      defs.h       Logical non-equivalence operator, !=.    
  3387. ISOCTAL      macro      ctype.h      True if arg is octal character.          
  3388. isoctal      function   isoctal.c    Returns TRUE if argument is octal digit. 
  3389. isok         function   isok.c       Prompts and accepts y/n answer.          
  3390. isprint      function   isprint.c    True if arg is printable character.      
  3391. ISPRINT      macro      ctype.h      True if arg is printable character.      
  3392. ispunct      function   ispunct.c    True if arg is punctuation.              
  3393. ISPUNCT      macro      ctype.h      True if arg is not cntrl or alphanum.    
  3394. isspace      function   isspace.c    True if arg is space, tab, or newline.   
  3395. ISSPACE      macro      ctype.h      True if arg is space, tab, or newline.   
  3396. isupper      function   isupper.c    True if arg is upper-case alpha.         
  3397. ISUPPER      macro      ctype        True if arg is upper case alpha.         
  3398. itoa         function   itoa.c       Integer-to-Ascii conversion.             
  3399. itoab        function   itoa.c       Based int-ASCII conversion.              
  3400. labs         function   labs.c       Absolute value function, long.           
  3401. LBITS        typedef    stdtyp.h     Long used only for bit manipulation.     
  3402. liberate     function   malloc.c     free() without header overhead.          
  3403. lmax         function   lminmax.c    Maximum of a, b: long.                   
  3404. lmin         function   lminmax.c    Minimum of a, b: long.                   
  3405. log          function   log.c        Natural logarithm, double.               
  3406. log10        function   log10.c      Common logarithm, double.                
  3407. LOG10e       constant   mathcons.h   Log of e base 10.                        
  3408. LOG10two     constant   mathcons.h   log of 2 base 10.                        
  3409. log2         function   log2.c       Logarithm, base 2, double.               
  3410. LOG2         constant   mathcons.h   Natural log of 2.                        
  3411. LOG2e        constant   mathcons.h   Log of e base 2.                         
  3412. LOGe10       constant   mathcons.h   log of 10 base e.                        
  3413. ltoa         function   ltoa.c       Long-to-ASCII conversion.                
  3414. ltoab        function   ltoa.c       Long to base conversion.                 
  3415. LURSHIFT     macro      defs.h       Long Unsigned Right Shift long n, b bits 
  3416. malloc       function   malloc.c     Storage allocator: get memory from OS.   
  3417. max          function   max.c        Maximum of two integers.                 
  3418. MAX          macro      defs.h       Maximum value of any two numbers.        
  3419. MAXANGLE     constant   mathcons.h   Maximum trigonometric angle, pi * 2^25.  
  3420. METACHAR     typedef    stdtyp.h     Augmented char to include EOF value.     
  3421. min          function   min.c        Minimum of two integer values.           
  3422. MIN          macro      defs.h       Minimum value of any two numeric values. 
  3423. modf         function   modf.c       Fraction and integer parts, double.      
  3424. NO           constant   defs.h       Standard NOt true value.                 
  3425. normscrn     function   scrnio.c     Return terminal to normal intensity.     
  3426. NOT          macro      defs.h       Logical negation operator, !.            
  3427. nprob        function   nprob.c      Normal probability function.             
  3428. nprobc       function   nprob.c      Normal probability tail function, double 
  3429. NULL         constant   defs.h       Standard NULL pointer value.             
  3430.  
  3431.              PORTABLE C LIBRARY SYSTEM-INDEPENDENT ELEMENTS (cont.)
  3432.  
  3433. Element      Type       File                    Description               
  3434.  
  3435. OR           macro      defs.h       Logical inclusive-or operator, ||.       
  3436. ORIGIN       constant   stdio.h      Beginning of file seek designator.       
  3437. outcol       int array  global.h     Global variable, output column for chan. 
  3438. outrow       int array  global.h     Global variable, output row for channel. 
  3439. PI           constant   mathcons.h   pi                                       
  3440. PIover2      constant   mathcons.h   pi / 2                                   
  3441. PIover3      constant   mathcons.h   pi / 3                                   
  3442. PIover4      constant   mathcons.h   pi / 4                                   
  3443. PIover6      constant   mathcons.h   pi / 6                                   
  3444. pow          function   pow.c        Power: raise x to y power, double.       
  3445. printf       function   printf.c     Formatted print to stdout.               
  3446. progname     TEXT       global.h     Standard global string to hold prog name 
  3447. putc         function   putc.c       Buffered char output to stream.          
  3448. putca        function   putc.c       Buffered ASCII character output.         
  3449. putchar      macro      stdio.h      Put car out to stdout.                   
  3450. puts         function   puts.c       Put string out to stdout.                
  3451. putscrn      function   scrnio.c     Put character directly to screen, unbuff 
  3452. qsort        function   qsort.c      Quicksort an array.                      
  3453. randexp      function   randexp.c    Random number, double, exponential dist. 
  3454. randize      function   random.c     Seed the random number generator.        
  3455. randnorm     function   randnorm.c   Random number, double, normal distrib.   
  3456. random       function   random.c     Random number, double, uniform distrib.  
  3457. ratfun       function   ratfun.c     Rational function evaluation, double.    
  3458. realloc      function   realloc.c    Change storage allocator block size.     
  3459. redirbuf     function   redirbuf.c   Set redirected i/o buffer size.          
  3460. rewind       function   rewind.c     Rewind buffered i/o medium to beginning. 
  3461. rindex       function   rindex.c     Find last occurrence of char in string.  
  3462. rknstep      function   rknstep.c    4-th order Runge-Kutta n-th order DE.    
  3463. rkstep       function   rkstep.c     4-th order Runge-Kutta 1-st order DE.    
  3464. ROOTHALF     constant   mathcons.h   sqrt(0.5)                                
  3465. ROOTTWO      constant   mathcons.h   sqrt(2.0)                                
  3466. round        function   round.c      Round to nearest integer, double.        
  3467. scanf        function   scanf.c      Formatted scan input from stdin.         
  3468. setbuf       function   setbuf.c     Assign memory buffer to i/o stream.      
  3469. SGN          macro      defs.h       Sign value: +1, 0, -1, any numeric type. 
  3470. sgn          function   sgn.c        Sign function: +1, 0, -1, double.        
  3471. simpson      function   simpson.c    Integration by Simpson's modified rule.  
  3472. sin          function   sin.c        Sine function, double.                   
  3473. sinh         function   sinh.c       Hyperbolic sine, double.                 
  3474. sortB        function   sortB.c      Bubble-sort array in memory, in-place.   
  3475. sortH        function   sortH.c      Heapsort an array, in-place in memory.   
  3476. sortQ        function   sortQ.c      Quicksort memory array, in place.        
  3477. sortS        function   sortS.c      Shell-sort memory array, in-place.       
  3478. sprintf      function   sprintf.c    Formatted output to string buffer.       
  3479. sqrt         function   sqrt.c       Square-root function, double.            
  3480. SQRT3        constant   mathcons.h   sqrt(3)                                  
  3481. SQRT3m1      constant   mathcons.h   sqrt(3.0) - 1.0                          
  3482. sscanf       function   sscanf.c     Formated scan input from string.         
  3483. STDERR       constant   stdio.h      Standard error output device number.     
  3484. stderr       macro      stdio.h      Standard buffered i/o error stream.      
  3485.  
  3486.              PORTABLE C LIBRARY SYSTEM-INDEPENDENT ELEMENTS (cont.) 
  3487.  
  3488. Element      Type       File                    Description               
  3489.  
  3490. STDIN        constant   stdio.h      Standard input device number.            
  3491. stdin        macro      stdio.h      Standard buffered input stream.          
  3492. STDOUT       constant   stdio.h      Standard output device number.           
  3493. stdout       macro      stdio.h      Standard buffered output stream.         
  3494. stradd       function   stradd.c     Multiple string concatenation.           
  3495. strcat       function   strcat.c     Concatenate two strings.                 
  3496. strcmp       function   strcmp.c     Compare two strings lexicographically.   
  3497. strcpy       function   strcpy.c     copy one string to another.              
  3498. streql       function   streql.c     Returns TRUE if strings are equal.       
  3499. strindex     function   strindex.c   Locate one string in another.            
  3500. STRING       typedef    stdtyp.h     Used only for pointers to strings.       
  3501. strlen       function   strlen.c     Compute length of string.                
  3502. strncat      function   strncat      Concatenate strings up to n chars.       
  3503. strncmp      function   strncmp.c    Compare strings up to n chars.           
  3504. strncpy      function   strncpy.c    Copy one string to another, up to n char 
  3505. strsave      function   strsave.c    Save (copy) a string to heap storage.    
  3506. SUCCESS      constant   defs.h       Standard non-FAIL value.                 
  3507. TABSTOP      macro      stdio.h      Number of spaces per tab stop.           
  3508. tan          function   tan.c        Tangent function, double.                
  3509. tanh         function   tanh.c       Hyperbolic tangent, double.              
  3510. TEXT         typedef    stdtyp.h     Used only for ASCII printable characters 
  3511. tiny         typedef    stdtyp.h     A char used for signed int work.         
  3512. tolower      function   tolower.c    Convert arg to lower-case, if upper.     
  3513. TOLOWER      macro      ctype.h      Convert arg to lower-case, if upper.     
  3514. toupper      function   toupper.c    Convert to upper case, if lower.         
  3515. TOUPPER      macro      ctype.h      Convert arg to upper case, if lower.     
  3516. TRUE         constant   defs.h       Standard truth value.                    
  3517. TWOLOG2e     constant   mathcons.h   2 * log2(e)                              
  3518. TWOmSQRT3    constant   mathcons.h   2 - sqrt(3)                              
  3519. TWOoverPI    constant   mathcons.h   2.0 / pi                                 
  3520. unformat     function   unformat.c   Basic scan function, arbitrary medium.   
  3521. ungetc       function   ungetc.c     Put char back into input stream.         
  3522. uniscrn      function   scrnio.c     Uninitialize terminal screen.            
  3523. urandom      function   random.c     Random number, unsigned, uniform distrib 
  3524. URSHIFT      macro      defs.h       Unsigned Right Shift, unsigned n, b bits 
  3525. utiny        typedef    stdtyp.h     A char used for unsigned int work.       
  3526. utoa         function   utoa.c       Unsigned to ASCII conversion.            
  3527. VOID         typedef    stdtyp.h     Used for function returning no value.    
  3528. YES          constant   defs.h       Standard truth value.                    
  3529. _ALLBUFF     constant   stdio.h      Allocated buffer flag mask.              
  3530. _BUSY        constant   stdio.h      File open (busy) flag mask.              
  3531. _EOF         constant   stdio.h      Buffered  stream end-of-file flag mask.  
  3532. _IOERR       constant   stdio.h      Buffered stream i/o error mask.          
  3533. _RDONLY      constant   stdio.h      File open signal to read only.           
  3534. _RDWRIT      constant   stdio.h      File open signal for read and write.     
  3535. _WRONLY      constant   stdio.h      File open signal for write-only access.  
  3536. .pa
  3537. .po6
  3538.                       Table 5-4: PORTABLE C LIBRARY ELEMENTS
  3539.  
  3540. Element      Type       File      Portable                 Description               
  3541.  
  3542. ABS          macro      defs.h       yes        Absolute value of any numeric type.      
  3543. abs          function   abs.c        yes        Absolute value function, int.            
  3544. acos         function   asin.c       yes        arc cosine, double.                      
  3545. ALIGN        typedef    stdtyp.h     customize  K & R storage allocation header aligner. 
  3546. allot        function   malloc.c     yes        malloc() without header overhead.         
  3547. altscrn      function   scrnio.c     yes        Set terminal to alternate intensity.     
  3548. ALTSCRN      TEXT       scrnio.h     customize  Terminal into alternate intensity string 
  3549. AND          macro      defs.h       yes        Logical "and" operator, &&.              
  3550. asin         function   asin.c       yes        Arc sine function, double.               
  3551. astof        function   atof.c       customize  ASCII number to (double) float. Pointer. 
  3552. astoi        function   atoi.c       yes        ASCII int to int. Also returns pointer.  
  3553. astol        function   atol         yes        ASCII to long. Also returns pointer.     
  3554. atan         function   atan.c       yes        Arc tangent, double.                     
  3555. atan2        function   atan.c       yes        Two-argument arc tangent, double.        
  3556. atof         function   atof.c       yes        ASCII to (double) float.                 
  3557. atoi         function   atoi.c       yes        ASCII to int.                            
  3558. atol         function   atol.c       yes        ASCII to long.                           
  3559. BIG10X       constant   mathcons.h   customize  Largest 10^(2^(BIG10X -1)) < INFINITY    
  3560. BIGX         constant   mathcons.h   customize  16 * log2(INFINITY) - 1                  
  3561. bitcount     function   bitcount.c   yes        K & R function counts bits in argument.  
  3562. BITS         typedef    stdtyp.h     yes        Short used only for bit manipulation.    
  3563. BOOL         typedef    stdtyp.h     yes        Int used only for boolean.               
  3564. BUFFER       typedef    stdtyp.h     yes        Used only for pointers to char buffers.  
  3565. BUFSIZ       constant   stdio.h      customize  I/O stream buffer size.                  
  3566. calloc       function   malloc.c     yes        C allocation for arrays.                 
  3567. CB4L         TBOOL      scrnio.h     customize  Column-before-row boolean.               
  3568. cbrt         function   cbrt.c       yes        Cube root function, double.              
  3569. CBRTFOUR     constant   mathcons.h   yes        Cube root of 4.                          
  3570. CBRTTWO      constant   mathcons.h   yes        Cube root of 2.                          
  3571. ceil         function   floor.c      yes        Ceiling function of double.              
  3572. chrstc       function   chrstc.c     customize  Return int characteristic of double.     
  3573. clearerr     macro      stdio.h      yes        Reset error indicator on file stream.    
  3574. CLEARSCREEN  TEXT       scrnio.h     customize  Terminal clear-screen string.            
  3575. close        function   csys.lib     system     Close file OS interface.                 
  3576. clrscrn      function   scrnio.c     yes        Clear terminal screen.                   
  3577. COFFSET      tiny       scrnio.c     customize  Cursor lead-in column offset value.      
  3578. cos          function   sin.c        yes        Cosine function, double.                 
  3579. cosh         function   cosh.c       yes        Hyperbolic cosine, double.               
  3580. cotan        function   tan.c        yes        Cotangent function, double.              
  3581. creat        function   csys.lib     system     Create file function, OS interface.      
  3582. CRINSUP      constant   stdio.h      customize  Set TRUE to suppress CR text input.      
  3583. CROUTADD     constant   stdio.h      customize  Set true to echo '\n' with CR.           
  3584. CURPOS       constant   stdio.h      yes        Current file position seek indicator.    
  3585. cursor       function   scrnio.c     yes        Position terminal cursor at row, column. 
  3586. DPRECISION   constant   mathcons.h   customize  (int) PRECISION                          
  3587. EDOM         constant   errno.h      yes        Function argument not in defined domain. 
  3588. EOF          constant   defs.h       yes        Standard End-of-File value.              
  3589. eprintf      function   eprintf.c    yes        Formatted print to stderr.               
  3590. eputc        macro      stdio.c      yes        Put character out to stderr.             
  3591. eputs        function   eputs.c      yes        Put string out to stderr.                
  3592. eraeol       function   scrnio.c     yes        Erase terminal screen to end of line.    
  3593.  
  3594.                        PORTABLE C LIBRARY ELEMENTS (cont.)
  3595.  
  3596. Element      Type       File      Portable                 Description
  3597.  
  3598. ERAEOLN      TEXT       scrnio.c     customize  Terminal Erase-to-End-of-Line string.    
  3599. eraeop       function   scrnio.c     yes        Erase terminal screen to end of page.    
  3600. ERAEOPG      TEXT       scrnio.h     customize  Terminal erase-to-end-of-page string.    
  3601. ERANGE       constant   errno.h      yes        Computed math value out of range.        
  3602. erf          function   erf.c        yes        Error function, double.                  
  3603. erfc         function   erf.c        yes        Complimentary error function, double.    
  3604. errno        short      global.h     yes        Standard error variable.                 
  3605. exit         function   csys.lib     system     Close all files and terminate program.   
  3606. exp          function   exp.c        yes        Exponential function, double.            
  3607. fabs         function   fabs.c       yes        Absolute value function, double.         
  3608. FADEOUT      constant   mathcons.h   yes        Magnitude of washout term in Taylor ser. 
  3609. FAIL         constant   defs.h       yes        Standard Failure value.                  
  3610. FALSE        constant   defs.h       yes        Standard False value.                    
  3611. FAST         macro      stdtyp.h     customize  Pseudo storage class (register).         
  3612. fclosall     function   putc.c       yes        Close all buffered i/o streams.          
  3613. fclose       function   fopen.c      yes        Close file using descriptor.             
  3614. feof         macro      stdio.h      yes        Evaluate end-of-file status, int.        
  3615. ferror       macro      stdio.h      yes        Boolean for file i/o error.              
  3616. fflush       function   fopen.c      yes        Flush file buffers to the medium.        
  3617. fgets        function   fgets.c      yes        Get string from file (buffered).         
  3618. FILE         typedef    stdio.h      yes        Standard file type declaration.          
  3619. FILEND       constant   stdio.h      yes        File end seek position designator.       
  3620. fileno       macro      stdio.h      yes        Return file descriptor of stream.        
  3621. fint         function   fint.c       customize  Float (double) INTeger-part function.    
  3622. floor        function   floor.c      yes        Floor function, double.                  
  3623. flush        function   putc.c       yes        Flush output buffer when char overflow.  
  3624. fmax         function   fminmax.c    yes        Maximum of a, b, double.                 
  3625. fmin         function   fminmax.c    yes        Minimum of a, b, double.                 
  3626. fopen        function   fopen.c      yes        Open file for buffered operation.        
  3627. FOREVER      macro      defs.h       yes        Same as "for (::)".                      
  3628. format       function   format.c     yes        Basic output format utility.             
  3629. FOURTHLOG2   constant   mathcons.h   yes        log(2) / 4                               
  3630. fprintf      function   fprintf.c    yes        Formatted output to file.                
  3631. fputs        function   fputs.c      yes        Put string out to file, unformatted.     
  3632. frac         function   frac.c       yes        Fractional-part function, double.        
  3633. fread        function   fread.c      yes        Buffered read from file.                 
  3634. free         function   malloc.c     yes        Free previously allocated storage.       
  3635. frexp        function   frexp.c      yes        Fraction (mantissa) and exponent, double 
  3636. fscanf       function   fscanf.c     yes        Formatted scan inputs from file.         
  3637. fseek        function   fseek.c      yes        Buffered file reposition function.       
  3638. ftell        function   ftell.c      yes        Return current file offset from origin.  
  3639. ftoa         function   ftoa.c       customize  Float (double) to ASCII conversion.      
  3640. fwrite       function   fwrite.c     yes        Buffered write to file.                  
  3641. getbuf       function   getbuf.c     yes        Get an i/o buffer from allot().          
  3642. getc         function   getc.c       yes        Get character from file.                 
  3643. getca        function   getc.c       yes        Get ASCII char from buffered i/o stream. 
  3644. getchar      macro      stdio.c      yes        Get character from stdin.                
  3645. getf         function   getf.c       yes        Prompt and get double from stdin.        
  3646. geti         function   geti.c       yes        Prompt and get integer from stdin.       
  3647. getl         function   getl.c       yes        Prompt and get long from stdin.          
  3648.  
  3649.                        PORTABLE C LIBRARY ELEMENTS (cont.)
  3650.  
  3651. Element      Type       File      Portable                 Description
  3652.  
  3653. getns        function   getns.c      yes        Prompt and get string from stdin.        
  3654. gets         function   gets.c       yes        Get string from stdin.                   
  3655. GLOBAL       macro      stdtyp.h     yes        Pseudo storage class (extern) for port.  
  3656. GZ           macro      defs.h       yes        Greater than Zero, GZ(x) = (x>0? x : 0)  
  3657. HALFLOG2e    constant   mathcons.h   yes        log2(e) / 4                              
  3658. HEADER       typedef    stdtyp.h     yes        K & R storage allocation block type.     
  3659. HEIGHT       tiny       scrnio.h     customize  Terminal height, number of lines.        
  3660. home         function   scrnio.c     yes        Home the terminal cursor.                
  3661. HOME         string     scrnio.h     customize  Terminal cursor-to-home (0,0) string.    
  3662. hypot        function   hypot.c      yes        Compute hypotenuse of right triangle.    
  3663. index        function   index.c      yes        Find position of char in string arg.     
  3664. INFINITY     constant   mathcons.h   customize  Largest double value on this machine.    
  3665. INFINLEG     constant   math.cons    customize  INFINITY / ROOTTWO.                      
  3666. iniscrn      function   scrnio.c     yes        Initialize terminal screen output.       
  3667. inverf       function   inverf.c     yes        Inverse of error function, erf, double.  
  3668. inverfc      function   inverf.c     yes        Inverse of complementart error function. 
  3669. INVPI        constant   mathcons.h   yes        1.0 / pi                                 
  3670. IObuffs      buffers    stdio.h      yes        I/O buffers for buffered streams.        
  3671. IS           macro      defs.h       yes        Logical equivalence operator, ==.        
  3672. isalnum      function   isalnum.c    yes        True if arg is alpha or number.          
  3673. ISALNUM      macro      ctype.h      yes        True if arg is alpha or number.          
  3674. isalpha      function   isalpha.c    yes        True if arg is alpha.                    
  3675. ISALPHA      macro      ctype.h      yes        True if arg is alpha.                    
  3676. isascii      function   isascii.c    yes        True if arg is < 128.                    
  3677. ISASCII      macro      ctype.h      yes        True if arg < 128.                       
  3678. iscntrl      function   iscntrl.c    yes        True if arg is control or DEL character. 
  3679. ISCNTRL      macro      ctype.h      yes        True if arg is control or DEL character. 
  3680. isdigit      function   isdigit.c    yes        True if arg is decimal digit.            
  3681. ISDIGIT      macro      ctype.h      yes        True if arg is decimal digit.            
  3682. ishex        function   ishex.c      yes        Returns TRUE if argument is hex number.  
  3683. islower      function   islower.c    yes        True if arg is lower-case alpha.         
  3684. ISLOWER      macro      ctype.h      yes        True if arg is lower case alpha.         
  3685. ISNT         macro      defs.h       yes        Logical non-equivalence operator, !=.    
  3686. ISOCTAL      macro      ctype.h      yes        True if arg is octal character.          
  3687. isoctal      function   isoctal.c    yes        Returns TRUE if argument is octal digit. 
  3688. isok         function   isok.c       yes        Prompts and accepts y/n answer.          
  3689. isprint      function   isprint.c    yes        True if arg is printable character.      
  3690. ISPRINT      macro      ctype.h      yes        True if arg is printable character.      
  3691. ispunct      function   ispunct.c    yes        True if arg is punctuation.              
  3692. ISPUNCT      macro      ctype.h      yes        True if arg is not cntrl or alphanum.    
  3693. isspace      function   isspace.c    yes        True if arg is space, tab, or newline.   
  3694. ISSPACE      macro      ctype.h      yes        True if arg is space, tab, or newline.   
  3695. isupper      function   isupper.c    yes        True if arg is upper-case alpha.         
  3696. ISUPPER      macro      ctype        yes        True if arg is upper case alpha.         
  3697. itoa         function   itoa.c       yes        Integer-to-Ascii conversion.             
  3698. itoab        function   itoa.c       yes        Based int-ASCII conversion.              
  3699. labs         function   labs.c       yes        Absolute value function, long.           
  3700. LBITS        typedef    stdtyp.h     yes        Long used only for bit manipulation.     
  3701. ldexp        function   frexp.c      customize  Load exponent (multiply by power of 2).  
  3702. LEADIN       TEXT       scrnio.h     customize  Cursor lead-in sequence.                 
  3703.  
  3704.                        PORTABLE C LIBRARY ELEMENTS (cont.)
  3705.  
  3706. Element      Type       File      Portable                 Description
  3707.  
  3708. LEAST        constant   mathcons.h   customize  Least double representable in machine.   
  3709. liberate     function   malloc.c     yes        free() without header overhead.          
  3710. LINDELETE    TEXT       scrnio.c     customize  Terminal line-delete string.             
  3711. LININSERT    TEXT       scrnio.h     customize  Terminal line-delete string.             
  3712. lmax         function   lminmax.c    yes        Maximum of a, b: long.                   
  3713. lmin         function   lminmax.c    yes        Minimum of a, b: long.                   
  3714. LOCAL        macro      stdtyp.h     customize  Pseudo storage class (static) for port.  
  3715. log          function   log.c        yes        Natural logarithm, double.               
  3716. log10        function   log10.c      yes        Common logarithm, double.                
  3717. LOG10e       constant   mathcons.h   yes        Log of e base 10.                        
  3718. LOG10two     constant   mathcons.h   yes        log of 2 base 10.                        
  3719. log2         function   log2.c       yes        Logarithm, base 2, double.               
  3720. LOG2         constant   mathcons.h   yes        Natural log of 2.                        
  3721. LOG2e        constant   mathcons.h   yes        Log of e base 2.                         
  3722. LOGe10       constant   mathcons.h   yes        log of 10 base e.                        
  3723. LOGINFINITY  constant   mathcons.h   customize  Largest argument of log function.        
  3724. LOGLEAST     constant   mathcons.h   customize  Log of smallest machine number           
  3725. lseek        function   csys.lib     system     Move file position using arg as offset.  
  3726. ltoa         function   ltoa.c       yes        Long-to-ASCII conversion.                
  3727. ltoab        function   ltoa.c       yes        Long to base conversion.                 
  3728. LURSHIFT     macro      defs.h       yes        Long Unsigned Right Shift long n, b bits 
  3729. malloc       function   malloc.c     yes        Storage allocator: get memory from OS.   
  3730. max          function   max.c        yes        Maximum of two integers.                 
  3731. MAX          macro      defs.h       yes        Maximum value of any two numbers.        
  3732. MAXANGLE     constant   mathcons.h   yes        Maximum trigonometric angle, pi * 2^25.  
  3733. MAXCHANNELS  constant   global.h     customize  Maximum number of i/o channels at once.  
  3734. MAXEXP       constant   mathcons.h   customize  Largest numeric characteristic.          
  3735. MAXEXPG      constant   mathcons.h   customize  MAXEXP - 3 guard bits.                   
  3736. MAXLINE      constant   stdio.h      customize  Maximum no. of chars. on input line.     
  3737. MAXSTREAM    constant   stdio.h      customize  Maximum number of buffered i/o streams.  
  3738. METACHAR     typedef    stdtyp.h     yes        Augmented char to include EOF value.     
  3739. min          function   min.c        yes        Minimum of two integer values.           
  3740. MIN          macro      defs.h       yes        Minimum value of any two numeric values. 
  3741. MINEXP       constant   mathcons.h   customize  Characteristic of least machine double.  
  3742. MINEXPG      constant   mathcons.h   customize  MINEXP + 3 guard bits.                   
  3743. modf         function   modf.c       yes        Fraction and integer parts, double.      
  3744. NALLOC       constant   stdtyp.h     customize  No. of HEADER units for malloc().         
  3745. NO           constant   defs.h       yes        Standard NOt true value.                 
  3746. normscrn     function   scrnio.c     yes        Return terminal to normal intensity.     
  3747. NORMSCRN     TEXT       scrnio.h     customize  Terminal string, return normal intensity 
  3748. NOT          macro      defs.h       yes        Logical negation operator, !.            
  3749. nprob        function   nprob.c      yes        Normal probability function.             
  3750. nprobc       function   nprob.c      yes        Normal probability tail function, double 
  3751. NULL         constant   defs.h       yes        Standard NULL pointer value.             
  3752. open         function   csys.lib     system     Open file for operation, OS interface.   
  3753. OR           macro      defs.h       yes        Logical inclusive-or operator, ||.       
  3754. ORIGIN       constant   stdio.h      yes        Beginning of file seek designator.       
  3755. outcol       int array  global.h     yes        Global variable, output column for chan. 
  3756. outrow       int array  global.h     yes        Global variable, output row for channel. 
  3757. PI           constant   mathcons.h   yes        pi                                       
  3758.  
  3759.                        PORTABLE C LIBRARY ELEMENTS (cont.)
  3760.  
  3761. Element      Type       File      Portable                 Description
  3762.  
  3763. PIover2      constant   mathcons.h   yes        pi / 2                                   
  3764. PIover3      constant   mathcons.h   yes        pi / 3                                   
  3765. PIover4      constant   mathcons.h   yes        pi / 4                                   
  3766. PIover6      constant   mathcons.h   yes        pi / 6                                   
  3767. PMODE        constant   stdio.h      customize  fopen() protection mode (for UNIX).      
  3768. pow          function   pow.c        yes        Power: raise x to y power, double.       
  3769. PRECISION    constant   mathcons.h   customize  -log10(WASHOUT).                         
  3770. printf       function   printf.c     yes        Formatted print to stdout.               
  3771. progname     TEXT       global.h     yes        Standard global string to hold prog name 
  3772. putc         function   putc.c       yes        Buffered char output to stream.          
  3773. putca        function   putc.c       yes        Buffered ASCII character output.         
  3774. putchar      macro      stdio.h      yes        Put car out to stdout.                   
  3775. puts         function   puts.c       yes        Put string out to stdout.                
  3776. putscrn      function   scrnio.c     yes        Put character directly to screen, unbuff 
  3777. qsort        function   qsort.c      yes        Quicksort an array.                      
  3778. randexp      function   randexp.c    yes        Random number, double, exponential dist. 
  3779. randize      function   random.c     yes        Seed the random number generator.        
  3780. randnorm     function   randnorm.c   yes        Random number, double, normal distrib.   
  3781. random       function   random.c     yes        Random number, double, uniform distrib.  
  3782. ratfun       function   ratfun.c     yes        Rational function evaluation, double.    
  3783. RCENDER      TEXT       scrnio.h     customize  Row-column lead-in terminator.           
  3784. RCSEPARATOR  TEXT       scrnio.h     customize  Cursor row, column separator string.     
  3785. read         function   csys.lib     system     Read from stream into buffer: OS interfc 
  3786. realloc      function   realloc.c    yes        Change storage allocator block size.     
  3787. redirbuf     function   redirbuf.c   yes        Set redirected i/o buffer size.          
  3788. rename       function   csys.lib     customize  Rename a file: OS interface.             
  3789. rewind       function   rewind.c     yes        Rewind buffered i/o medium to beginning. 
  3790. rindex       function   rindex.c     yes        Find last occurrence of char in string.  
  3791. rknstep      function   rknstep.c    yes        4-th order Runge-Kutta n-th order DE.    
  3792. rkstep       function   rkstep.c     yes        4-th order Runge-Kutta 1-st order DE.    
  3793. ROFFSET      tiny       scrnio.h     customize  Cursor lead-in row offset value.         
  3794. ROOTHALF     constant   mathcons.h   yes        sqrt(0.5)                                
  3795. ROOTTWO      constant   mathcons.h   yes        sqrt(2.0)                                
  3796. round        function   round.c      yes        Round to nearest integer, double.        
  3797. RTHLFINF     constant   mathcons.h   customize  sqrt(INFINITY / 2).                      
  3798. sbrk         function   csys.lib     system     Set pointer to available memory: OS i/f. 
  3799. scanf        function   scanf.c      yes        Formatted scan input from stdin.         
  3800. SCRNINI      TEXT       scrnio.h     customize  Initialize-terminal string.              
  3801. SCRNUNI      TEXT       scrnio.h     customize  Terminal un-initialize string.           
  3802. SCRNWRAP     TBOOL      scrnio.h     customize  Signal for auto terminal wrap-around.    
  3803. setbuf       function   setbuf.c     yes        Assign memory buffer to i/o stream.      
  3804. SGN          macro      defs.h       yes        Sign value: +1, 0, -1, any numeric type. 
  3805. sgn          function   sgn.c        yes        Sign function: +1, 0, -1, double.        
  3806. simpson      function   simpson.c    yes        Integration by Simpson's modified rule.  
  3807. sin          function   sin.c        yes        Sine function, double.                   
  3808. sinh         function   sinh.c       yes        Hyperbolic sine, double.                 
  3809. SMALLX       constant   mathcons.h   customize  16 * log2(LEAST) + 1.0                   
  3810. sortB        function   sortB.c      yes        Bubble-sort array in memory, in-place.   
  3811. sortH        function   sortH.c      yes        Heapsort an array, in-place in memory.   
  3812. sortQ        function   sortQ.c      yes        Quicksort memory array, in place.        
  3813.  
  3814.                        PORTABLE C LIBRARY ELEMENTS (cont.)
  3815.  
  3816. Element      Type       File      Portable                 Description
  3817.  
  3818. sortS        function   sortS.c      yes        Shell-sort memory array, in-place.       
  3819. sprintf      function   sprintf.c    yes        Formatted output to string buffer.       
  3820. sqrt         function   sqrt.c       yes        Square-root function, double.            
  3821. SQRT3        constant   mathcons.h   yes        sqrt(3)                                  
  3822. SQRT3m1      constant   mathcons.h   yes        sqrt(3.0) - 1.0                          
  3823. sscanf       function   sscanf.c     yes        Formated scan input from string.         
  3824. STDERR       constant   stdio.h      yes        Standard error output device number.     
  3825. stderr       macro      stdio.h      yes        Standard buffered i/o error stream.      
  3826. STDIN        constant   stdio.h      yes        Standard input device number.            
  3827. stdin        macro      stdio.h      yes        Standard buffered input stream.          
  3828. STDOUT       constant   stdio.h      yes        Standard output device number.           
  3829. stdout       macro      stdio.h      yes        Standard buffered output stream.         
  3830. stradd       function   stradd.c     yes        Multiple string concatenation.           
  3831. strcat       function   strcat.c     yes        Concatenate two strings.                 
  3832. strcmp       function   strcmp.c     yes        Compare two strings lexicographically.   
  3833. strcpy       function   strcpy.c     yes        copy one string to another.              
  3834. streql       function   streql.c     yes        Returns TRUE if strings are equal.       
  3835. strindex     function   strindex.c   yes        Locate one string in another.            
  3836. STRING       typedef    stdtyp.h     yes        Used only for pointers to strings.       
  3837. strlen       function   strlen.c     yes        Compute length of string.                
  3838. strncat      function   strncat      yes        Concatenate strings up to n chars.       
  3839. strncmp      function   strncmp.c    yes        Compare strings up to n chars.           
  3840. strncpy      function   strncpy.c    yes        Copy one string to another, up to n char 
  3841. strsave      function   strsave.c    yes        Save (copy) a string to heap storage.    
  3842. SUCCESS      constant   defs.h       yes        Standard non-FAIL value.                 
  3843. SYMLEAST     constant   mathcons.h   customize  Symmetric Least value (1/SYMLEAST) exist 
  3844. SYS_EOF      macro      stdio.h      customize  System end-of-file marker, if any.       
  3845. TABSTOP      macro      stdio.h      yes        Number of spaces per tab stop.           
  3846. tan          function   tan.c        yes        Tangent function, double.                
  3847. tanh         function   tanh.c       yes        Hyperbolic tangent, double.              
  3848. TANHXBIG     constant   mathcons     customize  (No. sig bits + 2) * log(2) / 2          
  3849. TBITS        typedef    stdtyp.h     customize  Tiny (8 char min) for bit manipulation.  
  3850. TBOOL        typedef    stdtyp.h     customize  Tiny (8 char min) used tor boolean.      
  3851. TERMINAL     TEXT       scrnio.h     customize  Terminal identification string.          
  3852. TEXT         typedef    stdtyp.h     yes        Used only for ASCII printable characters 
  3853. tiny         typedef    stdtyp.h     yes        A char used for signed int work.         
  3854. TINY         macro      stdtyp.h     customize  rvalue for tiny.                         
  3855. tolower      function   tolower.c    yes        Convert arg to lower-case, if upper.     
  3856. TOLOWER      macro      ctype.h      yes        Convert arg to lower-case, if upper.     
  3857. toupper      function   toupper.c    yes        Convert to upper case, if lower.         
  3858. TOUPPER      macro      ctype.h      yes        Convert arg to upper case, if lower.     
  3859. TRUE         constant   defs.h       yes        Standard truth value.                    
  3860. TWOLOG2e     constant   mathcons.h   yes        2 * log2(e)                              
  3861. TWOmSQRT3    constant   mathcons.h   yes        2 - sqrt(3)                              
  3862. TWOoverPI    constant   mathcons.h   yes        2.0 / pi                                 
  3863. unformat     function   unformat.c   yes        Basic scan function, arbitrary medium.   
  3864. ungetc       function   ungetc.c     yes        Put char back into input stream.         
  3865. uniscrn      function   scrnio.c     yes        Uninitialize terminal screen.            
  3866. unlink       function   csys.lib     system     Unlink a file name from a file (delete). 
  3867. urandom      function   random.c     yes        Random number, unsigned, uniform distrib 
  3868.  
  3869.                        PORTABLE C LIBRARY ELEMENTS (cont.)
  3870.  
  3871. Element      Type       File      Portable                 Description
  3872.  
  3873. URSHIFT      macro      defs.h       yes        Unsigned Right Shift, unsigned n, b bits 
  3874. USELAST      TBOOL      scrnio.h     customize  Signal to use final terminal column.     
  3875. utiny        typedef    stdtyp.h     yes        A char used for unsigned int work.       
  3876. UTINY        macro      stdtyp.h     customize  rvalue for utiny.                        
  3877. utoa         function   utoa.c       yes        Unsigned to ASCII conversion.            
  3878. VOID         typedef    stdtyp.h     yes        Used for function returning no value.    
  3879. WASHOUT      constant   mathcons.h   customize  1.0 + (x < WASHOUT) = 1.0 to precision.  
  3880. WIDTH        tiny       scrnio.h     customize  Terminal width, number of characters.    
  3881. write        function   csys.lib     system     File write OS interface.                 
  3882. XLT2ASCII    TBOOL      scrnio.h     customize  Translate-to-ASCII boolean.              
  3883. YES          constant   defs.h       yes        Standard truth value.                    
  3884. _ALLBUFF     constant   stdio.h      yes        Allocated buffer flag mask.              
  3885. _BUSY        constant   stdio.h      yes        File open (busy) flag mask.              
  3886. _EOF         constant   stdio.h      yes        Buffered  stream end-of-file flag mask.  
  3887. _exit        function   csys.lib     system     Immediate termination of program.        
  3888. _IOERR       constant   stdio.h      yes        Buffered stream i/o error mask.          
  3889. _RDONLY      constant   stdio.h      yes        File open signal to read only.           
  3890. _RDWRIT      constant   stdio.h      yes        File open signal for read and write.     
  3891. _WRONLY      constant   stdio.h      yes        File open signal for write-only access.  
  3892. .po 17
  3893.  
  3894.  
  3895. Customization Procedure
  3896.  
  3897.      To  customize and install the C language portable subroutine 
  3898. (function)  library on a new host,  the procedure is  roughly  as 
  3899. follows:
  3900.  
  3901.      1.  Determine  the  extent to which the 10 system  functions 
  3902.          given  in  Table 5-1 (i.e.,  all but rename)  exist  and 
  3903.          satisfy  the  interface specifications in Section  3  of 
  3904.          this  manual.   Determine  the  system  run-time-support 
  3905.          interface  requirements  within  the  supplied   library 
  3906.          file(s).
  3907.  
  3908.      2.  Program  a rename function and convert it to relocatable 
  3909.          form   suitable  for  the   linking   loader.    Modify, 
  3910.          reprogram,  or create any of the 10 system functions and 
  3911.          basic  runtime-support functions to make them conform to 
  3912.          the interface, and similarly convert them to relocatable 
  3913.          form.    If   redirected  i/o  is  handled  within   the 
  3914.          accessible system functions,  alter these as appropriate 
  3915.          to  call  redirbuf  to expand  stdin  or  stdout  stream 
  3916.          buffers  to  BUFSIZ;  otherwise  redirected i/o  may  be 
  3917.          considerably slower.
  3918.  
  3919.      3.  Extract  the remaining (conformant) system functions  in 
  3920.          Table 5-1 and all system run-time-support functions from 
  3921.          the existing host C function library,  and insert all of 
  3922.          the system interface functions into a library or archive 
  3923.          file using the host library maintenance program, call it 
  3924.          csys.lib   (or   csys.a,   etc.,   depending   on   host 
  3925.          restrictions).   Observe topological sorting precedences 
  3926.          imposed by the system.
  3927.  
  3928.      4.  Customize  the functions and parameters listed in  Table 
  3929.          5-2,  and  recompile  all functions in  the  portable  C 
  3930.          library,  using  the  host  C compiler,  into  the  form 
  3931.          expected  by  the linking loader.   Combine  these  with 
  3932.          csys.lib   functions,    observing   topological    sort 
  3933.          precedences,  into a new library file,  call it lib0.lib 
  3934.          (or other, depending on host restrictions).
  3935.  
  3936.      If  the  original  host C library  contains  functions  that 
  3937. satisfy  the functional descriptions herein given  exactly,  then 
  3938. they  may  be  extracted  from this  library  and  included  into 
  3939. lib0.lib in lieu of the portable-source version, if desired.
  3940.  
  3941.  
  3942. Customization Example
  3943.  
  3944.      The  procedure  outlined  in  the  preceding  paragraphs  is 
  3945. perhaps best detailed by illustration.   The following steps were 
  3946. taken  to  install the portable C library functions into  a  file 
  3947. acceptable  for  the  AZTEC-II  (Version  1.50,   copyright  Manx 
  3948. Software Systems,  Shrewsbury,  NJ) C compiler on a microcomputer 
  3949. with CP/M (a trademark of Digital Research,  Inc., Pacific Grove, 
  3950. CA)  operating  system.   The C library file delivered  with  the 
  3951. compiler was named libc.lib.
  3952.  
  3953.      1.  Study of existing system:
  3954.  
  3955.          a.  In extracting the system interface from libc.lib, it 
  3956.          was  noted that _exit was absent,  but all other  system 
  3957.          functions were present.
  3958.  
  3959.          b.   The  sbrk function (and an internally-used  callcpm 
  3960.          function) did not function properly.
  3961.  
  3962.          c.   The  STDIN read function always buffered characters 
  3963.          until a newline was received.
  3964.  
  3965.          d.   Redirected output was handled within the C  system, 
  3966.          and if redirected to a file,  was very slow, one written 
  3967.          character per disk access.
  3968.  
  3969.          e.   The  C  run-time  system  invoked  strcpy,  strcat, 
  3970.          strcmp,  and  strlen  functions within  the  portable  C 
  3971.          library being installed.
  3972.  
  3973.          f.   The system invoked a function closall_ to flush all 
  3974.          open streams and close all files, and a function putterr 
  3975.          to output a character to STDERR.
  3976.  
  3977.      2.  Corrective system actions:
  3978.  
  3979.          a.   rename  was present and correct within the supplied 
  3980.          system, thus not reprogrammed.
  3981.  
  3982.          b.   The  function  puterr(c) was  made,  equivalent  to 
  3983.          write(STDERR, &c, 1).
  3984.  
  3985.          c.   The _exit function was programmed as a direct  jump 
  3986.          to the reboot function of the CP/M operating system.
  3987.  
  3988.          d.   A correctly functioning version of sbrk and callcpm 
  3989.          were  available  in source form on  the  vendor-supplied 
  3990.          diskettes;  these  were compiled and substituted for the 
  3991.          functions extracted from libc.lib.
  3992.  
  3993.          e.  A closeall_ function was programmed to call fclosall 
  3994.          (a  function  within putc);   whenever  buffered  output 
  3995.          functions  are used,  output streams are  thus  properly 
  3996.          flushed  and closed by exit.   A dummy fclosall function 
  3997.          file was provided merely to close all open files in  the 
  3998.          event output is unbuffered (putc not used).
  3999.  
  4000.          f.  Fortunately, the source code was available for read, 
  4001.          so  it  was modified to deliver  single-character  input 
  4002.          immediately, without waiting for a newline.
  4003.  
  4004.          g.   Since source code was available, it was possible to 
  4005.          alter  the  system croot function to call redirbuf  when 
  4006.          input or output is redirected to a file.  Note that both 
  4007.          getc  and  putc  contain  unreachable  code  to   invoke 
  4008.          redirbuf;  when STDIN or STDOUT is redirected to a file, 
  4009.          its stream buffer is thus expanded from 1 to BUFSIZ.   A 
  4010.          file,  dredir.c,  containing a do-nothing dummy redirbuf 
  4011.          was  supplied  for loading when stdio.h streams are  not 
  4012.          used.
  4013.  
  4014.      3.  Create system interface library.
  4015.  
  4016.      All  system functions were archived by the  library  manager 
  4017. function  into  the C system interface  library,  csys.lib.   The 
  4018. contents and order of functions in the file are:
  4019.  
  4020.      supp8080  fsubs     puterr    uexit     callcpm   croot
  4021.      closall   dfclose   open      read      write     lseek
  4022.      blkio     rename    unlink    block     lsubs     sbrk
  4023.      dredir    strlen    strcpy    strcmp    strcat    stradd
  4024.  
  4025. Note  that  it was necessary to include strlen and  other  string 
  4026. functions  in  this file,  because they were invoked  within  the 
  4027. system functions (actually, croot).
  4028.  
  4029.      4.  Customize, compile, and form function library.
  4030.  
  4031.      Constants, floating-point number formats, and other elements 
  4032. to be customized were made to conform with the AZTEC-II  compiler 
  4033. specifications.  See the following files for details:
  4034.  
  4035.      atof.c    chrstc.c  defs.h    errno.h   fint.c    frexp.c
  4036.      ftoa.c    global.h  mathcons.h          scrnio.h  stdio.h
  4037.      stdtyp.h
  4038.  
  4039.      All  non-math library functions were compiled and  collected 
  4040. into the file lib0.lib in the following order:
  4041.  
  4042.      random    getf      geti      getl      isok      getns
  4043.      sortB     sortH     sortS     bitcount  scrnio    printf
  4044.      eprintf   fprintf   sprintf   fscanf    format    eputs
  4045.      sscanf    scanf     fwrite    unformat  fputs     ftoa
  4046.      fgets     puts      putc      fopen     rewind    qsort
  4047.      fseek     fread     gets      getc      redirbuf  getbuf
  4048.      atof      strsave   realloc   sortq     atoi      setbuf
  4049.      isupper   islower   ispunct   isoctal   ishex     isprint
  4050.      iscntrl   isascii   isalnum   atol      malloc    rindex
  4051.      min       max       lminmax   labs      itoa      ftell
  4052.      ungetc    index     ltoa      isdigit   isspace   isalpha
  4053.      abs       utoa      tolower   toupper   strncmp   strncal
  4054.      strindex  streql    strncpy
  4055.  
  4056.      A  separate library file,  mathlib,  was made to contain the 
  4057. mathematical functions:
  4058.  
  4059.      asin      randnorm  randexp   hypot     cosh      cbrt
  4060.      sqrt      tanh      tan       sinh      sin       nprob
  4061.      inverf    erf       rkstep    rknstep   pow       floor
  4062.      exp       log2      log10     log       frexp     sgn
  4063.      ratfun    fminmax   modf      chrstc    round     frac
  4064.      fint      fabs      atan      simpson
  4065.  
  4066.      Due to the fact that the vendor linkage editor was incapable 
  4067. of working with files larger that 64K,  it was necessary to leave 
  4068. the library in these three segments.
  4069. .pa o
  4070. .heappendix                                                 appendix
  4071. .PN 1
  4072. .FO                                A-#
  4073.                        A. R E F E R E N C E S 
  4074.  
  4075.  
  4076. 1.   UNIX Programmer's Manual, Bell Telephone Laboratories, Inc., 
  4077.      Murray Hill, New Jersey, 1983.
  4078.  
  4079. 2.   Kernighan,   Brian  W.,   and  Ritchie,  Dennis  M.,  The  C 
  4080.      Programming Language, Prentice-Hall, Inc., Englewood Cliffs, 
  4081.      New Jersey, 1978.
  4082.  
  4083. 3.   Handbook  of  Mathematical  Functions,  National  Bureau  of 
  4084.      Standards  Applied Mathematics Series #55,  U.S.  Government 
  4085.      Printing Office, Washington, D.C., 1964.
  4086.  
  4087. 4.   Plum,   Thomas,  C  Programming  Standards  and  Guidelines, 
  4088.      Version U (UNIX and offspring),  Plum Hall,  Inc.,  Cardiff, 
  4089.      New Jersey, 1982.
  4090.  
  4091. 5.   Coty,  William J.,  Jr., and Waite, William, Software Manual 
  4092.      for  the  Elementary  Functions,   Prentice-Hall  Series  in 
  4093.      Computational Mathematics,  Prentice-Hall,  Inc.,  Inglewood 
  4094.      Cliffs, New Jersey, 1980.
  4095.  
  4096. 6.   J.  F. Hart, E. W. Cheney, C. L. Lawson, H. J. Maehly, C. K. 
  4097.      Mesztenyi,  J. R. Rice, H. C. Thacher, Jr., and C. Witzgall, 
  4098.      Computer Approximations,  John Wiley & Sons, Inc., New York, 
  4099.      New York, 1968.
  4100.  
  4101. 7.   Schonfelder,  J.  L., Mathematics of Computation, Volume 32, 
  4102.      No. 144, October, 1978, pp. 1232-1240.
  4103.  
  4104. 8.   Blair,  J.  M.,  et. al., "Rational Chebyshev Approximations 
  4105.      for the Inverse Error Function", Mathematics of Computation, 
  4106.      Volume 30, No. 136, October, 1976.
  4107.  
  4108. 9.   Wirth,  Nicklaus,  Algorithms  + Data Structures = Programs, 
  4109.      Prentice-Hall, Inc., Englewood Cliffs, New Jersey, 1976. 
  4110.  
  4111. 10.  Aho,  Alfred v.,  Hopcroft, John E., and Ullman, Jeffrey D., 
  4112.      The  Design  and Analysis of Computer  Algorithms,  Addison-
  4113.      Wesley Publishing Company, Reading, Massachusetts, 1975, pp. 
  4114.      87-92.
  4115.  
  4116. 11.  Knuth,  Donald  E.,  Art of Computer  Programming,  Vol.  2, 
  4117.      Semi-Numerical   Algorithms,    Addison-Wesley    Publishing 
  4118.      Company, Reading, Massachusetts, 1973.
  4119.  
  4120. 12.  Tausworthe,  R.  C.,  "Random  numbers  generated by  linear       
  4121.      recurrence modulo two",  Mathematics of Computation,  Volume       
  4122.      19, 1965, pp. 201-209.
  4123.  
  4124. 13.  Purdom,   Jack,  The  C  Programmer's  Library,  Que  Corp., 
  4125.      Indianapolis, 1984.
  4126.  
  4127.  
  4128. 14.  The C User's Group Newsletters,  McPhereson,  K. S., Vol. I, 
  4129.      No. 1, June, 1981, through Vol. II, No. 6, March, 1985.
  4130.  
  4131. 15.  Portable  C Subroutine  Library,  Vol.  II,  Jet  Propulsion 
  4132.      Laboratory, 1985.
  4133. .pa o
  4134. .PN 1
  4135. .FO                                B-#
  4136.                            B. I N D E X 
  4137. .FI B:USEGUIDE.IDX
  4138.